-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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 socket send() immediately back to back after connect() #22630
Fix TCP socket send() immediately back to back after connect() #22630
Conversation
7f2abe4
to
3f02d35
Compare
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.
lgtm % nits
test/test_sockets.py
Outdated
@@ -350,6 +350,11 @@ def test_posix_proxy_sockets(self): | |||
# Build and run the TCP echo client program with Emscripten | |||
self.btest_exit('websocket/tcp_echo_client.c', args=['-lwebsocket', '-sPROXY_POSIX_SOCKETS', '-pthread', '-sPROXY_TO_PTHREAD']) | |||
|
|||
# Test that multiple pthreads calling send() on the same socket produces correct ordering semantics. | |||
def test_sockets_send_immediately_after_connect(self): |
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.
How about calling it test_sockets_send_while_connecting
?
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.
sure
… to send() back to back right after connecting, the send would fail because the socket is not yet actually connected. It is a bit hard to imagine where that behavior would be useful. So this PR changes this behavior to be identical to how connectionless UDP sockets are emulated: instead, connect() calls are always pretended to succeed (since we cannot synchronously establish if the connect would fail, so presume it'll work), and all send() calls that are issued while the socket is connecting will be queued to be sent after the socket actually connects.
6fbbb76
to
cdd575e
Compare
emscripten-core#22662 Merge remote-tracking branch 'origin/main' into fix_tcp_socket_send_immediately_after_connect
Previously, if an emulated TCP socket is connect()ed and one attempts to send() back to back right after connecting, the send would fail because the socket is not yet actually connected.
It is a bit hard to imagine where such behavior would be useful.
So this PR changes this behavior to be identical to how connectionless UDP sockets are emulated: instead, connect() calls are always pretended to succeed (since we cannot synchronously establish if the connect would fail, so presume it'll work), and all send() calls that are issued while the socket is connecting will be queued to be sent after the socket actually connects.