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

Attempt to concurrently connect to remote IP addresses #11757

Merged
merged 2 commits into from
Sep 5, 2019

Conversation

ClearlyClaire
Copy link
Contributor

Currently, Mastodon tries to connect one IP at a time, which means it will waste time if the first IP address it tries is unreachable.

Furthermore, it should address the following scenario:

  • instance A has two IP addresses
  • the first one is unreachable to instance B, the second is reachable to instance B
  • A issues a request to B, who needs to fetch a resource at A before replying
  • B timeouts on the first address, and thus can only reply after the timeout duration
  • which means A timeouts before allowing B to reply

@ClearlyClaire ClearlyClaire force-pushed the features/concurrent-connect branch 4 times, most recently from 3bc18e3 to 27114ab Compare September 4, 2019 15:57
raise HTTP::TimeoutError, "Connect timed out after #{Request::TIMEOUT[:connect]} seconds"
end
socks << sock
addr_by_socket[sock] = sockaddr
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not super happy about having a socket as a hash key, but I'm not sure how else to make the sockaddr corresponding to the socket when doing the IO.select bit. Should be fine in practice.

@ClearlyClaire ClearlyClaire force-pushed the features/concurrent-connect branch 2 times, most recently from 058aca8 to 2cf1c45 Compare September 4, 2019 16:22
@Gargron Gargron merged commit 1653b58 into mastodon:master Sep 5, 2019
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
* Attempt to concurrently connect to remote IP addresses

* Reduce code length to please CodeClimate 🤷
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.

None yet

2 participants