This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: fcntl(F_SETFD) on a file or socket handle
"Corinna Vinschen" <cygwin@cygwin.com> wrote:
> > Analyzing Cygwin code, it seems I have found the source of the problem (had no
> > time to confirm it running offending code though).
> >
> > It's in the fhandler_base::set_inheritance() called from fhandler_base::set_close_on_exec().
> >
> > DuplicateHandle()/CloseHandle() invalidates original system handle associated
> > with the Cygwin internal file descriptor (fd) while an operation on the fd is
> > possibly still in progress.
>
> Thanks for the hint.
>
> That should unlikely be the cause, except you're running plain win95.
> If you take a look into fhandler_socket.cc, you'll see that the
> fhandler_socket class defines it's own set_close_on_exec() method
> which doesn't call set_inheritance() when running Winsock2.
I see that fhandler_socket::fcntl() calls fhandler_base::fcntl() in
all cases different from F_SETFL. Perhaps my understanding of things
in C++ is not enough (I'm an old hand plain C programmer).
> OTOH, there seem to be a bug in 1.3.2 which could result in using
> Winsock1.1 methods even if Winsock2 is available. Hmm, but the
> cause should be exactly the other way around: Due to the error,
> Winsock1.1 methods are used for inheritance but w/o calling
> set_inheritance() before... However, you're reporting that problem is
> in the snapshots as well...
>
> Are you using win95, perhaps?
No, I'm using Win2000 SP2.
> Could you please start the application
> under strace and check, which Winsock version is used? Just look
> for a block of lines with the text "wsock_init" like that:
>
> 2326 339805 [main] ssh-agent 1760 wsock_init: res 0
> 157 339962 [main] ssh-agent 1760 wsock_init: wVersion 514
> 81 340043 [main] ssh-agent 1760 wsock_init: wHighVersion 514
> 78 340121 [main] ssh-agent 1760 wsock_init: szDescription WinSock 2.0
> 78 340199 [main] ssh-agent 1760 wsock_init: szSystemStatus Running
> 77 340276 [main] ssh-agent 1760 wsock_init: iMaxSockets 0
> 74 340350 [main] ssh-agent 1760 wsock_init: iMaxUdpDg 0
> 74 340424 [main] ssh-agent 1760 wsock_init: lpVendorInfo 0
I have the same numbers as in your trace.
--
Dmitry.
--
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/