-
Notifications
You must be signed in to change notification settings - Fork 855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows style WSL SO_REUSEADDR behaviour makes RPC over TCP unreliable #3909
Comments
Meh, can't exactly fault you for it. I strongly suspect (but can't prove) this will go chirping crickets without a repro test case with CLI steps, an But consider: (a) the underlying Well, you be the judge. Either way, great Cygwin reference and hat-tip on your work around. |
Yes, I can't imagine a simple solution here (changing Windows behaviour and potentially breaking native applications is clearly not an option, and I imagine wrapping the socket implementation for WSL is likely a big effort that would also carry performance implications). But at least it's captured and might save others some head scratching. I suspect as WSL applications grow, some differences like this may have to be addressed by multi-platform code on the Linux side, but clearly I'm no authority on that :) |
The standard approach for such problems: A compatibility flag (in the Windows TCP/IP driver) on the socket. The flag would be set internally by WSL using WSK and externally by Cygwin in inside its
Yes and thanks again. I am just not sure there are two actionable here: this and #2915. Or put another way, I can't see #2915 being fixed, but not your framing of the problem. |
Your Windows build number:
What you're doing and what's happening:
clnttcp_create
from libc.clnttcp_create
is called without passing a pre-bound socket to use, it callsbindresvport
to find an unused privileged (<1024) source port to use.bindresvport
returns a port that then causesconnect
to fail withEADDRINUSE
clnttcp_create
to fail, returning an errorWhat's wrong / what should be happening instead:
bindresvport
relies on UNIX style behaviour when callingbind
on a socket withoutSO_REUSEADDR
set. That is forEADDRINUSE
to occur if there is still a connection in stateTIME_WAIT
associated with that socket.bind
will succeed in the case of existingTIME_WAIT
connections on a socket.connect
to fail as above.clnttcp_create
was patched to work around it. See http://cygwin.1069669.n5.nabble.com/Re-RPC-clnt-create-adress-already-in-use-td138927.htmlI realise there are already open issues regarding WSL behaviour with
SO_REUSEADDR
set, (eg. #2915) but I don't see any for the difference withoutSO_REUSEADDR
, hence adding this one. Hope that's the right thing to do.(For now I'm working around this by
LD_PRELOAD
ing a wrapper forclnttcp_create
which retriesbindresvport
to get another port in case of theconnect
error - this was somewhat simpler than the cygwin approach and 'works for me').The text was updated successfully, but these errors were encountered: