Subject: Re: socket/fdopen/exec problem
From: Corinna Vinschen <[email-masked]>
To: "Pierre A. Humblet" <[email-masked]>
Cc: cygwin <[email-masked]>
Date: Fri, 25 Jan 2002 17:10:21 +0100

On Fri, Jan 25, 2002 at 10:39:30AM -0500, Pierre A. Humblet wrote:
> Consider the following
> 
> /> netstat -a | fgrep 999    <=== daemon is running
>   TCP    PHumblet:999           0.0.0.0:0              LISTENING
> /> kill -HUP 293             <==== re-exec
> /> netstat -a | fgrep 999    <==== only one listen. OK
>   TCP    PHumblet:999           0.0.0.0:0              LISTENING
> /> telnet localhost 999
> Trying 127.0.0.1...
> Connected to PHumblet
> Escape character is '^]'.
> Hello world                  <=== OK, daemon is answering 
>                                       and forking a worker  
> telnet> quit
> Connection closed.
> /> netstat -a | fgrep 999  
> The following is fine. The daemon is listening and the previous 
> telnet connection is being closed.
>   TCP    PHumblet:999           0.0.0.0:0              LISTENING
>   TCP    PHumblet:999           localhost:2678         CLOSE_WAIT
>   TCP    PHumblet:2678          localhost:999          FIN_WAIT_2
> /> kill -HUP 293             <=== HUP the daemon, which reexecs itself
> /> netstat -a | fgrep 999
>   TCP    PHumblet:999           0.0.0.0:0              LISTENING
>   TCP    PHumblet:999           0.0.0.0:0              LISTENING
>   TCP    PHumblet:999           localhost:2678         CLOSE_WAIT
>   TCP    PHumblet:2678          localhost:999          FIN_WAIT_2
> This is strange. There are now listeners. The only difference with
> the first kill -HUP above is that a child process (forked by the 
> telnet call) is currently running. 
> /> telnet localhost 999
> Trying 127.0.0.1...
> Connected to PHumblet
> Escape character is '^]'.             <= nobody answered
> Connection closed by foreign host.    <= got this much later, when child exited
> 
> This is bad. The incoming call was not answered (no Hello world). 
> 
> The connection was closed when the child process terminated
> and the second listen went away at the same time.
> So the child is interfering with the listen of the parent.
> 
> After the child exits, things go back to normal. With exim
> on Win98, netstat shows that the several listeners stay forever
> and incoming calls are never answered...
> 
> Any thoughts?

Not immediately.  Two questions:

- Did you encounter the same on NT?

- Could you patch Cygwin fhandler_socket.cc, fhandler_socket::close()
  and rip out the whole linger stuff so that only the naked closesocket()
  call remains and see if that changes the behaviour?

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:[email-masked]
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/