Skip to content
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

[catnap] Windows: connect incorrectly signals completion #971

Open
kyleholohan opened this issue Oct 14, 2023 · 0 comments
Open

[catnap] Windows: connect incorrectly signals completion #971

kyleholohan opened this issue Oct 14, 2023 · 0 comments
Labels
bug Something Isn't Working

Comments

@kyleholohan
Copy link
Contributor

Description

In catnap/socket.rs impl Socket method try_connect calls connect on the underlying socket2::Socket. The result handling code from this call treats the WSAEWOULDBLOCK error code as positive confirmation of connection. If the user then issues another operation on the socket prior to the connection completing, the user may see unpredictable behavior.

How to Reproduce

int qt;
assert(demi_connect(&qt, ...) == 0);
assert(demi_wait(&qr, qt, ...) == 0);
assert(demi_pop(&qt, ...) == 0);

demi_wait(&qr, qt, ...) == ?

The final demi_wait call may indicate WSAENOTCONN.

Expected Behavior

demi_wait should not indicate completion of a complete qt until the underlying connection is established. This likely requires the catnap backend to poll the completion state of the connection. An example can be found in socket2 internals: sys::poll_connect for the Windows target.

Related Issues

None

@kyleholohan kyleholohan added the bug Something Isn't Working label Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something Isn't Working
Projects
None yet
Development

No branches or pull requests

1 participant