-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
std.posix
: unlock nonblocking connect()
use case
#24002
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it feasible to add a test for what this fixes in std/posix/test.zig
?
This comment was marked as outdated.
This comment was marked as outdated.
Ah, the tests in Actually, there might be an existing (but disabled, see #18315) test in place that might be fixed with your changes: Lines 380 to 406 in 4f3b59f
(would need to be verified that it'll no longer be flaky, though; ideally that'd be something like reproducing the failure, making the failure consistent if possible, and then showing that the changes fix the failure) |
I moved the test to I think the issue with the |
CI Failed. Turns out Linux and BSD refuse the connection to a nonexistent socket... Any ideas for a scenario that works on mac and linux? |
@@ -4274,6 +4274,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne | |||
const rc = windows.ws2_32.connect(sock, sock_addr, @intCast(len)); | |||
if (rc == 0) return; | |||
switch (windows.ws2_32.WSAGetLastError()) { | |||
.WSAEISCONN => return, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason WSAEISCONN
/ISCONN
shouldn't return an error (something like error.IsConnected
)? Is there no use case for distinguishing between success and WSAEISCONN
/ISCONN
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know of one, I opted for this because it makes total sense to me. Could opt for an error as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to wait for a Zig core team member to weigh in.
Match Windows `WSAEALREADY` with Linux `EALREADY` return gracefully when socket reports it is connected
Match Windows
WSAEALREADY
with LinuxEALREADY
return gracefully when socket reports it is connected
for easy reference the msdn page and the man page.
The msdn page also says that
WSAEINVAL
should be handled the same due to ambiguities. TheWSAConnect
api doesn't mention the same in the documentation. Is that a reason to change toWSAConnect
?