https://bugs.winehq.org/show_bug.cgi?id=53058
Bug ID: 53058 Summary: Incorrect socket reconnect behavior for DGRAM sockets Product: Wine Version: 6.13 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winsock Assignee: wine-bugs@winehq.org Reporter: aman560900@hotmail.com Distribution: ---
Expected behavior: Reconnecting with a DGRAM socket (specifically UDP) should not fail
Observed behavior: Reconnecting fails with WSAEISCONN
Breaking commit and change: https://github.com/wine-mirror/wine/commit/3b33a6b4873d2d75418c298880766f63b...
Both Windows and Linux kernels implement this correctly, with wine being the sole divergence. SockDoConnect in mswsock.dll shows the logic flow, SOCK_STREAM should fail with WSAEISCONN, but SOCK_DGRAM should not.
https://bugs.winehq.org/show_bug.cgi?id=53058
Peter winebug@stather.me changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |winebug@stather.me
https://bugs.winehq.org/show_bug.cgi?id=53058
--- Comment #1 from Peter winebug@stather.me --- Created attachment 72465 --> https://bugs.winehq.org/attachment.cgi?id=72465 sock.c patch
This is a patch which fixes the issue as far as we can tell and there *shouldn't* be any unintended side effects.
https://bugs.winehq.org/show_bug.cgi?id=53058
Zeb Figura z.figura12@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |z.figura12@gmail.com
--- Comment #2 from Zeb Figura z.figura12@gmail.com --- (In reply to Peter from comment #1)
Created attachment 72465 [details] sock.c patch
This is a patch which fixes the issue as far as we can tell and there *shouldn't* be any unintended side effects.
Hmm, I wonder if it's the right place to solve the problem, though. I wonder if we should never be setting DGRAM sockets to SOCK_CONNECTED state in the first place. There are only a few places where SOCK_CONNECTED is treated differently from SOCK_CONNECTIONLESS, but I dont think we have tests for whether any of those should apply to connectionless sockets.
https://bugs.winehq.org/show_bug.cgi?id=53058
--- Comment #3 from Peter winebug@stather.me --- (In reply to Zeb Figura from comment #2)
(In reply to Peter from comment #1)
Created attachment 72465 [details] sock.c patch
This is a patch which fixes the issue as far as we can tell and there *shouldn't* be any unintended side effects.
Hmm, I wonder if it's the right place to solve the problem, though. I wonder if we should never be setting DGRAM sockets to SOCK_CONNECTED state in the first place. There are only a few places where SOCK_CONNECTED is treated differently from SOCK_CONNECTIONLESS, but I dont think we have tests for whether any of those should apply to connectionless sockets.
I can't say I'm an expert on any of this, was just heavily involved in the testing and debugging process for working out why our code doesn't work (a BF4 mod btw, which the regressing commit was meant to fix <_<).
It would make sense that a connectionless socket, which I think UDP DGRAM sockets, are should be handled as such.
https://bugs.winehq.org/show_bug.cgi?id=53058
--- Comment #4 from aman560900@hotmail.com --- (In reply to Zeb Figura from comment #2)
(In reply to Peter from comment #1)
Created attachment 72465 [details] sock.c patch
This is a patch which fixes the issue as far as we can tell and there *shouldn't* be any unintended side effects.
Hmm, I wonder if it's the right place to solve the problem, though. I wonder if we should never be setting DGRAM sockets to SOCK_CONNECTED state in the first place. There are only a few places where SOCK_CONNECTED is treated differently from SOCK_CONNECTIONLESS, but I dont think we have tests for whether any of those should apply to connectionless sockets.
While I can't recommend the solution proposed by Peter as the most correct, it seems to be consistent with the Windows kernel, and at least behaviorally, the Linux kernel as well.
Maybe a better solution would be to prevent connectionless sockets from reaching the SOCK_CONNECTED state?
https://bugs.winehq.org/show_bug.cgi?id=53058
--- Comment #5 from Zeb Figura z.figura12@gmail.com --- I did some testing, and it seems that none of the places we handle SOCK_CONNECTED should apply to connectionless sockets. I've written some patches which I'll submit upstream soon.
https://bugs.winehq.org/show_bug.cgi?id=53058
--- Comment #6 from Peter winebug@stather.me --- (In reply to Zeb Figura from comment #5)
I did some testing, and it seems that none of the places we handle SOCK_CONNECTED should apply to connectionless sockets. I've written some patches which I'll submit upstream soon.
Nice, looking forward too it. Thanks for taking the time to fix it.
https://bugs.winehq.org/show_bug.cgi?id=53058
Zeb Figura z.figura12@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED Fixed by SHA1| |8a4433d6a7755fb6b156563b166 | |a9993f54c8103
--- Comment #7 from Zeb Figura z.figura12@gmail.com --- This was delayed longer than I meant it to (sorry about that), but should be fixed upstream by https://source.winehq.org/git/wine.git/commitdiff/8a4433d6a7755fb6b156563b166a9993f54c8103.
https://bugs.winehq.org/show_bug.cgi?id=53058
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #8 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 7.14.