-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
[3.x] [Net] Remove blocking network address resolution in connect_to_host in websockets #53243
Conversation
6ab4649
to
7bf08a8
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.
As mentioned multiple times, changes need to be PRed against the master
branch first.
#53262 for master |
fixes #53265 for websocket clients |
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 am deeply sorry for the very long review time, I have been sucked up by the work on the replication API.
This change looks okay, it is a bit of a mess that this has to be handled down in every peer separately, but it's definitely an improvement so I would merge this once the review comments are addressed.
Good work 👍
Vector<String> _protocols; | ||
Vector<String> _original_protocols; |
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 understand why we need the _original_protocols
.
It seems there is already the _protocols
variable that could be used.
_connection = _tcp; | ||
|
||
_key = WSLPeer::generate_key(); | ||
// TODO custom extra headers (allow overriding this too?) |
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.
We can remove this TODO since we now support extra headers (was a leftover from the other PR I guess).
I meant to review the master PR, please disregard this review
71cb8d3
to
c58391c
Compare
This commit removes blocking address resolution in
connect_to_host
in websockets. This is similar to what happens in HTTPClient.Currently a few other peer's implementations of
connect_to_host
still include a blocking call toresolve_hostname
which unfortunately can block ingetaddrinfo
for an unspecified amount of time. This is not good, considering there is a good chance many projects are callingconnect_to_host
on the main engine thread.This PR addresses one of the peers (websocket) with an resolving state, which is similar to what happens in HTTPClient.
I'm hoping eventually we can clean up these connection status state enums into something shared among all the network classes, but until then this and the rest of the network classes
connect_to_host
implementations should follow what HttpClient does. (Have an intermediate resolving state to avoid blocking inconnect_to_host
).As an aside, (as someone who's gone through Apple App review too many times), I'm pretty sure their test environment includes a laggy DNS response env. I have seen app review bring this up a few time with different app submissions, and indeed our project was using the websocket
connect_to_host
, and ended up pausing the main thread for much too long waiting for a hostname to resolve. This was easily confirmed with the iOS link conditioner, and setting a manual delay for dns resolution time.