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

Immediately try next connection when one attempt fails and fix possible race conditions (happy eyeballs) #232

Merged
merged 4 commits into from
May 15, 2020

Conversation

clue
Copy link
Member

@clue clue commented May 14, 2020

This changeset ensures a new connection attempt will be started immediately when one connection attempt fails. This is quite common when connecting on IPv4-only systems where the first IPv6 connection will fail and the next connection attempt should not have to wait 100ms.

The 100ms delay between connection attempts now only triggers when the connection attempt is still pending. Afaict this is not in violation of RFC 8305 and seems to be in line with how other implementations handle this specific situation (https://daniel.haxx.se/blog/2020/03/16/curl-ootw-happy-eyeballs-timeout/, https://www.isc.org/blogs/2011-01-19-multi-homed-server-over-tcp/, curl/curl#2281 and others).

This can easily be reproduced by connecting to localhost:1 when nothing is listening on this port. Prior to this patch, this would take around ~160ms on my system, after applying this patch it takes around ~50ms. Likewise, connection setup is improved on IPv4-only systems (such as Docker in its default configuration) when the destination is reachable over both IPv6 and IPv4.

Additionally, this changeset fixes two subtle bugs when the connector rejects immediately and when DNS resolves with the same IP address multiple times.

Builds on top of #231, #230, #224 and #225

@clue clue added this to the v1.5.0 milestone May 14, 2020
@clue clue requested review from WyriHaximus and jsor May 14, 2020 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants