-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
Fix: TCP handling code is not posix compliant #9142
Conversation
When calling send or receive on a non-blocking socket, we only check for EWOULDBLOCK for partial completion, even though POSIX mandates that the call could return either EWOULDBLOCK or EAGAIN.
I expect this to fail on our Windows CIs, but it is running now, so we will see in a moment :) |
Oh, I wasn't aware that the windows code also ran that code path. Doesn't winsock define its own error codes though? I don't understand how EWOULDBLOCK would work on windows in that case. |
Bit of cross-posting, but I asked in the upstream ticket if serenity only fires Historical, these 2 could be triggered for different circumstances, but in reality the OSes (and libcs) we support don't do this anymore for decades now. So it makes me wonder if we should change all our The main reason I was triggered by this, as because for Windows there is no need to check 2 values, so it all becomes a bit derpy. The other solution would be to make it a function in I might also be overthinking this completely :P EDIT: upstream indicates they only fire |
Oh, so it's Serenity will probably end up defining both of them to the same number anyway (to simplify other ports), so this PR wouldn't really be needed on our end, but I figure it might be worth merging anyway, since it's a POSIX thing and other operating systems may assume it works this way. We could do a similar trick as the EWOULDBLOCK windows hack to make sure the windows version works, just add |
Yeah, Windows is annoying. It defines As alternative to your PR, maybe something like this works too: Follows the portability advise of POSIX, without us having to worry about it ever again. Not sure it is a better solution, but while I fight that out with other devs, would you mind testing if that in fact also does solve the issue? :D Tnx! |
I pulled your branch, it works on serenity. I think that is a better way to solve it, I'll leave this PR open for now until you guys have figured out which approach you like. :) |
Motivation / Problem
When calling send or receive on a non-blocking socket, we only check for EWOULDBLOCK for partial completion, even though POSIX mandates that the call could return either EWOULDBLOCK or EAGAIN. This means that on certain operating systems that return EAGAIN from these functions (and don't define them as being the same error code), all of the TCP code would be broken.
Description
We check whether errno is set to EWOULDBLOCK or EAGAIN, instead of just EWOULDBLOCK.
Limitations
I believe I've fixed every bit of code that uses EWOULDBLOCK/EAGAIN in this project. General POSIX compatibility may still be unsolved.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.