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

feat: parallelize IMAP and SMTP connection attempts #5915

Merged
merged 11 commits into from
Aug 28, 2024

Conversation

link2xt
Copy link
Collaborator

@link2xt link2xt commented Aug 25, 2024

Previously for each connection candidate (essentially host and port pair) after resolving the host to a list of IPs Delta Chat iterated IP addresses one by one. Now for IMAP and SMTP we try up to 5 IP addresses in parallel. We start with one connection and add more connections later. If some connection fails, e.g. we try to connect to IPv6 on IPv4 network and get "Network is unreachable" (ENETUNREACH) error, we replace failed connection with another one immediately.

IPv6 addresses do not get any special priority. IP address prioritization happens in lookup_host_with_cache and currently addresses that are known to work recently are returned first.

For HTTP there is a follow-up PR #5921 that replaces reqwest and hyper-util connection code with custom connection establishment and direct usage of hyper client. Currently hyper-util implements https://datatracker.ietf.org/doc/html/rfc6555 and tries at most two connection at a time: one IPv6 and one IPv4, with IPv4 attempts delayed by 300 ms on dual-stack hosts if both IPv6 and IPv4 addresses are returned.

Closes #5799

@link2xt link2xt force-pushed the link2xt/parallel-connection-attempts branch from 07ac754 to cdaefb4 Compare August 25, 2024 07:52
Base automatically changed from link2xt/always-use-preloaded-dns to main August 25, 2024 15:33
@link2xt link2xt force-pushed the link2xt/parallel-connection-attempts branch 4 times, most recently from 31d6e54 to 260a697 Compare August 26, 2024 13:48
@link2xt link2xt marked this pull request as ready for review August 26, 2024 13:54
@link2xt link2xt changed the title feat: parallelize connection attempts feat: parallelize IMAP and SMTP connection attempts Aug 26, 2024
@link2xt link2xt requested a review from iequidoo August 26, 2024 13:59
@link2xt link2xt force-pushed the link2xt/parallel-connection-attempts branch from ecb5dd5 to 28659d1 Compare August 26, 2024 19:25
@link2xt link2xt removed the request for review from iequidoo August 27, 2024 04:19
@link2xt link2xt marked this pull request as draft August 27, 2024 04:19
@link2xt link2xt force-pushed the link2xt/parallel-connection-attempts branch from 28659d1 to e7fbeb7 Compare August 27, 2024 19:56
@link2xt link2xt marked this pull request as ready for review August 27, 2024 20:02
@link2xt link2xt force-pushed the link2xt/parallel-connection-attempts branch from ea8c1ed to 42dc962 Compare August 28, 2024 00:07
@link2xt link2xt requested review from iequidoo and Hocuri August 28, 2024 12:03
Copy link
Collaborator

@Hocuri Hocuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now 🎉!

@link2xt link2xt merged commit aab8ef2 into main Aug 28, 2024
37 checks passed
@link2xt link2xt deleted the link2xt/parallel-connection-attempts branch August 28, 2024 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parallelize connection attempts to IPv6 and IPv4
2 participants