| Index: net/socket/transport_client_socket_pool.cc
|
| diff --git a/net/socket/transport_client_socket_pool.cc b/net/socket/transport_client_socket_pool.cc
|
| index 7527eca52edf547d3e75a102bf8b79374ba846a8..bec8dc72dca2ff77a706cd1cf4220fb3e61d4bfd 100644
|
| --- a/net/socket/transport_client_socket_pool.cc
|
| +++ b/net/socket/transport_client_socket_pool.cc
|
| @@ -25,6 +25,8 @@
|
| #include "net/socket/tcp_client_socket.h"
|
|
|
| using base::TimeDelta;
|
| +extern bool g_tcp_fastopen_user_enabled;
|
| +extern bool g_tcp_fastopen_supported;
|
|
|
| namespace net {
|
|
|
| @@ -60,12 +62,24 @@ TransportSocketParams::TransportSocketParams(
|
| const HostPortPair& host_port_pair,
|
| bool disable_resolver_cache,
|
| bool ignore_limits,
|
| - const OnHostResolutionCallback& host_resolution_callback)
|
| + const OnHostResolutionCallback& host_resolution_callback,
|
| + CombineConnectAndWritePolicy combine_connect_and_write_if_supported)
|
| : destination_(host_port_pair),
|
| ignore_limits_(ignore_limits),
|
| - host_resolution_callback_(host_resolution_callback) {
|
| + host_resolution_callback_(host_resolution_callback),
|
| + combine_connect_and_write_(combine_connect_and_write_if_supported) {
|
| if (disable_resolver_cache)
|
| destination_.set_allow_cached_response(false);
|
| + // combine_connect_and_write currently translates to TCP FastOpen.
|
| + // Enable TCP FastOpen if user wants it and system supports it.
|
| + if (!g_tcp_fastopen_supported) {
|
| + combine_connect_and_write_ = COMBINE_CONNECT_AND_WRITE_PROHIBITED;
|
| + } else {
|
| + if (g_tcp_fastopen_user_enabled &&
|
| + combine_connect_and_write_ == COMBINE_CONNECT_AND_WRITE_DEFAULT) {
|
| + combine_connect_and_write_ = COMBINE_CONNECT_AND_WRITE_DESIRED;
|
| + }
|
| + }
|
| }
|
|
|
| TransportSocketParams::~TransportSocketParams() {}
|
| @@ -261,10 +275,25 @@ int TransportConnectJob::DoTransportConnect() {
|
| transport_socket_ =
|
| helper_.client_socket_factory()->CreateTransportClientSocket(
|
| helper_.addresses(), net_log().net_log(), net_log().source());
|
| - int rv = transport_socket_->Connect(helper_.on_io_complete());
|
| - if (rv == ERR_IO_PENDING &&
|
| +
|
| + // If the list contains IPv6 and IPv4 addresses, the first address will
|
| + // be IPv6, and the IPv4 addresses will be tried as fallback addresses,
|
| + // per "Happy Eyeballs" (RFC 6555).
|
| + bool try_ipv6_connect_with_ipv4_fallback =
|
| helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV6 &&
|
| - !AddressListOnlyContainsIPv6(helper_.addresses())) {
|
| + !AddressListOnlyContainsIPv6(helper_.addresses());
|
| +
|
| + // Enable TCP FastOpen if indicated by transport socket params.
|
| + // Note: We currently do not turn on TCP FastOpen for destinations where
|
| + // we try a TCP connect over IPv6 with fallback to IPv4.
|
| + if (!try_ipv6_connect_with_ipv4_fallback &&
|
| + helper_.params()->combine_connect_and_write() ==
|
| + TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DESIRED) {
|
| + transport_socket_->EnableTCPFastOpen();
|
| + }
|
| +
|
| + int rv = transport_socket_->Connect(helper_.on_io_complete());
|
| + if (rv == ERR_IO_PENDING && try_ipv6_connect_with_ipv4_fallback) {
|
| fallback_timer_.Start(
|
| FROM_HERE,
|
| base::TimeDelta::FromMilliseconds(
|
|
|