This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: fcntl(F_SETFD) on a file or socket handle


On Thu, Sep 20, 2001 at 12:24:06PM +0900, Dmitry Timoshkov wrote:
> "Corinna Vinschen" <cygwin@cygwin.com> wrote:
> 
> [skipped]
> 
> > > I didn't investigate it further, and probably will not have time in the near
> > > future to do so. Sorry.
> > 
> > :-(
> > 
> > You could at least send a testcase if you don't want to debug it.
> 
> 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.  

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?  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

Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]