[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: nam - no display



When nam starts up, it tries to listen on a socket. In order to find a
suitable port address, it does a linear search starting from 24443. If it
fails to allocate a socket on an address, it assumes that Tcl will
automatically close the socket so it doesn't close it. It turns out that
this assumption is wrong; when Tcl's socket returns error, nam still needs
to explicitly close it. Here is the patch, please let me know if it
doesn't help. Thanks. 

- Haobo

--------------------------------------

--- anim-ctrl.tcl       1999/02/18 18:31:04     1.18
+++ anim-ctrl.tcl       1999/03/04 18:48:14
@@ -79,6 +79,14 @@
                incr NAM_PORT_
                set ret [catch {set NAM_SOCK_ \
                        [socket -server ::AnimCtrlOnRemoteRequest $NAM_PORT_]}]
+               if {$ret} {
+                       # Failed, delete the socket
+                       close $NAM_SOCK_
+                       if {$NAM_PORT_ - $INIT_PORT > 254} {
+                               error "Nam failed to create a socket ranging \
+from $INIT_PORT_ to $NAM_PORT_."
+                       }
+               }
        }
 
        # Write that to a lock file, which resides under home directory

--------------------------------


On Thu, 4 Mar 1999, Russert, Steven W wrote:

> Thanks to Christian Joensson for the suggestion to use STRACE nam to find out what is holding up the works.  The problem on the surface is, indeed, "too many open files".  It looks like something might be in a loop, though.  Here is the kind of entry I see in the trace output by STRACE.  
> ...
> socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 5
> fcntl(5,F_SETFD, FD_CLOEXEC)                    =0
> getsockopt(5, SOL_SOCKET, SO_SNDBUF, [65535], [4]) = 0
> getsockopt(5, SOL_SOCKET, SO_RCVBUF, [65535], [4]) = 0
> getsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], [4]) = 0
> bind(5, {sin_family=AF_INET, sin_port=htons(24445), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
> listen(5,128)
> socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 6
> fcntl(6,F_SETFD, FD_CLOEXEC)                    =0
> getsockopt(6, SOL_SOCKET, SO_SNDBUF, [65535], [4]) = 0
> getsockopt(6, SOL_SOCKET, SO_RCVBUF, [65535], [4]) = 0
> getsockopt(6, SOL_SOCKET, SO_REUSEADDR, [1], [4]) = 0
> bind(6, {sin_family=AF_INET, sin_port=htons(24446), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
> listen(6,128)
> socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 7
> FCNTL(7,F_SETFD, FD_CLOEXEC)                    =0
> getsockopt(7, SOL_SOCKET, SO_SNDBUF, [65535], [4]) = 0
> getsockopt(7, SOL_SOCKET, SO_RCVBUF, [65535], [4]) = 0
> getsockopt(7, SOL_SOCKET, SO_REUSEADDR, [1], [4]) = 0
> bind(7, {sin_family=AF_INET, sin_port=htons(24447), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
> listen(7,128)
> ...
> This continues with incrementing numbers until it hits 255, then I get 
> 
> socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = -1 EMFILE (Too many open files)
> ...
> repeatedly, until the process is killed.
> 
> Any pointers on where I should look for the source of this problem?
> 
> 
> Thanks,
> 
> Steven W. Russert
> Boeing Phantom Works M&CT
> [email protected]
> 425-865-3588
> 
> 
> 
>