This is the mail archive of the cygwin-developers@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]
Other format: [Raw text]

Re: Fixing openssh to avoid occasional spurious connection failures

[Get raw message]
>  Date: Thu, 15 Nov 2001 23:06:25 +0100
>  From: Corinna Vinschen <vinschen@redhat.com>
>  
>  Don't think so.  I think we could find a workaround by assigning
>  local socket numbers in another range (>32768 or so).

This will not solve the problem.

If you read my test program, you will see that I am calling bind() on
the socket before connect(), and the bind() succeeds *** even though
the connect subsequently fails with WSAEADDRINUSE ***.  So there's no
way to detect that winsock has assigned an in-use port to the socket
until it's too late.

To do what you've proposed, i.e., to detect in connect() if the user
hasn't already called bind(), and if so, call bind() ourselves with a
known-good port, we'd have to keep a table somewhere of known-good
ports, and how could we do that?  First of all, there's noplace to
keep information that needs to be shared between cygwin processes (the
heap is inherited, not shared), and second of all, other, non-cygwin
applications would be free to use ports in this range too, and we
wouldn't know about them.

And what about if the user *does* call bind() explicitly, such that we
can't mess with the port number because one has already been assigned,
and it turns out that that port number is already in use (and that
won't be detected until the user calls connect())?  There's nothing at
all we can do to solve that case.

  jik


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