Merge 84251, 85083, 85188, 85375.
Add a fallback socket connect() for IPv6.
When a hostname has both IPv6 and IPv4 addresses, and the IPv6 address is listed first, we start a timer (300ms) (deliberately chosen to be different from the backup connect job). If the timer fires, that means the IPv6 connect() hasn't completed yet, and we start a second socket connect() where we give it the same AddressList, except we move all IPv6 addresses that are in front of the first IPv4 address to the end. That way, we will use the first IPv4 address. We will race these two connect()s and pass the first one to complete to ConnectJob::set_socket().
Adds 4 new TCP connection latency histograms to assess the new behavior:
IPv6 raceable (includes both when it races and doesn't, which are distinguished
by whether or not the samples exceed the race timeout of 300ms)
IPv6 solo (no IPv4 addresses to race against)
IPv4 no race (IPv4 is the first address, so we're not racing)
IPv4 wins race (IPv4 raced and won, even though it started behind).
TEST=On Linux, drop ip6 packets via `sudo ip6tables -A OUTPUT -p tcp -j DROP`. Then test against a site with both IPv6 and IPv4 addresses (such as www.ripe.net
). It should load without hitting 20s connect() timeouts on the IPv6 addresses.