Index: net/socket/tcp_socket_libevent.h |
diff --git a/net/socket/tcp_socket_libevent.h b/net/socket/tcp_socket_libevent.h |
index 4cbf692a0fbe6d5668526467664dd5b4b2862f57..0958b6d25d0f3e522524452bcb8e87281e3368fb 100644 |
--- a/net/socket/tcp_socket_libevent.h |
+++ b/net/socket/tcp_socket_libevent.h |
@@ -88,52 +88,72 @@ class NET_EXPORT TCPSocketLibevent { |
private: |
// States that using a socket with TCP FastOpen can lead to. |
- enum FastOpenStatus { |
- FAST_OPEN_STATUS_UNKNOWN, |
+ enum TCPFastOpenStatus { |
+ TCP_FASTOPEN_STATUS_UNKNOWN, |
- // The initial TCP FastOpen connect attempted returned synchronously, |
+ // The initial FastOpen connect attempted returned synchronously, |
// indicating that we had and sent a cookie along with the initial data. |
- FAST_OPEN_FAST_CONNECT_RETURN, |
+ TCP_FASTOPEN_FAST_CONNECT_RETURN, |
- // The initial TCP FastOpen connect attempted returned asynchronously, |
+ // The initial FastOpen connect attempted returned asynchronously, |
// indicating that we did not have a cookie for the server. |
- FAST_OPEN_SLOW_CONNECT_RETURN, |
+ TCP_FASTOPEN_SLOW_CONNECT_RETURN, |
// Some other error occurred on connection, so we couldn't tell if |
- // TCP FastOpen would have worked. |
- FAST_OPEN_ERROR, |
+ // FastOpen would have worked. |
+ TCP_FASTOPEN_ERROR, |
- // An attempt to do a TCP FastOpen succeeded immediately |
- // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
+ // An attempt to do a FastOpen succeeded immediately |
+ // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
// had acked the data we sent. |
- FAST_OPEN_SYN_DATA_ACK, |
+ TCP_FASTOPEN_SYN_DATA_ACK, |
- // An attempt to do a TCP FastOpen succeeded immediately |
- // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
+ // An attempt to do a FastOpen succeeded immediately |
+ // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
// had nacked the data we sent. |
- FAST_OPEN_SYN_DATA_NACK, |
+ TCP_FASTOPEN_SYN_DATA_NACK, |
- // An attempt to do a TCP FastOpen succeeded immediately |
- // (FAST_OPEN_FAST_CONNECT_RETURN) and our probe to determine if the |
- // socket was using TCP FastOpen failed. |
- FAST_OPEN_SYN_DATA_FAILED, |
+ // An attempt to do a FastOpen succeeded immediately |
+ // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and our probe to determine if the |
+ // socket was using FastOpen failed. |
+ TCP_FASTOPEN_SYN_DATA_GETSOCKOPT_FAILED, |
- // An attempt to do a TCP FastOpen failed (FAST_OPEN_SLOW_CONNECT_RETURN) |
+ // An attempt to do a FastOpen failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN) |
// and we later confirmed that the server had acked initial data. This |
// should never happen (we didn't send data, so it shouldn't have |
// been acked). |
- FAST_OPEN_NO_SYN_DATA_ACK, |
+ TCP_FASTOPEN_NO_SYN_DATA_ACK, |
- // An attempt to do a TCP FastOpen failed (FAST_OPEN_SLOW_CONNECT_RETURN) |
+ // An attempt to do a FastOpen failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN) |
// and we later discovered that the server had nacked initial data. This |
- // is the expected case results for FAST_OPEN_SLOW_CONNECT_RETURN. |
- FAST_OPEN_NO_SYN_DATA_NACK, |
+ // is the expected case results for TCP_FASTOPEN_SLOW_CONNECT_RETURN. |
+ TCP_FASTOPEN_NO_SYN_DATA_NACK, |
- // An attempt to do a TCP FastOpen failed (FAST_OPEN_SLOW_CONNECT_RETURN) |
+ // An attempt to do a FastOpen failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN) |
// and our later probe for ack/nack state failed. |
- FAST_OPEN_NO_SYN_DATA_FAILED, |
- |
- FAST_OPEN_MAX_VALUE |
+ TCP_FASTOPEN_NO_SYN_DATA_GETSOCKOPT_FAILED, |
+ |
+ // The initial FastOpen connect+write succeeded immediately |
+ // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and a subsequent attempt to read from |
+ // the connection failed. |
+ TCP_FASTOPEN_FAST_CONNECT_READ_FAILED, |
+ |
+ // The initial FastOpen connect+write failed |
+ // (TCP_FASTOPEN_SLOW_CONNECT_RETURN) |
+ // and a subsequent attempt to read from the connection failed. |
+ TCP_FASTOPEN_SLOW_CONNECT_READ_FAILED, |
+ |
+ // We didn't try FastOpen because it had failed in the past |
+ // (g_tcp_fastopen_has_failed was true.) |
+ // NOTE: This status is currently registered before a connect/write call |
+ // is attempted, and may capture some cases where the status is registered |
+ // but no connect is subsequently attempted. |
+ // TODO(jri): The expectation is that such cases are not the common case |
+ // with TCP FastOpen for SSL sockets however. Change code to be more |
+ // accurate when TCP FastOpen is used for more than just SSL sockets. |
+ TCP_FASTOPEN_PREVIOUSLY_FAILED, |
+ |
+ TCP_FASTOPEN_MAX_VALUE |
}; |
void AcceptCompleted(scoped_ptr<TCPSocketLibevent>* tcp_socket, |
@@ -158,14 +178,14 @@ class NET_EXPORT TCPSocketLibevent { |
void WriteCompleted(const scoped_refptr<IOBuffer>& buf, |
const CompletionCallback& callback, |
- int rv) const; |
- int HandleWriteCompleted(IOBuffer* buf, int rv) const; |
+ int rv); |
+ int HandleWriteCompleted(IOBuffer* buf, int rv); |
int TcpFastOpenWrite(IOBuffer* buf, |
int buf_len, |
const CompletionCallback& callback); |
- // Called when the socket is known to be in a connected state. |
- void RecordFastOpenStatus(); |
+ // Called after the first read completes on a TCP FastOpen socket. |
+ void UpdateTCPFastOpenStatusAfterRead(); |
scoped_ptr<SocketLibevent> socket_; |
scoped_ptr<SocketLibevent> accept_socket_; |
@@ -173,9 +193,14 @@ class NET_EXPORT TCPSocketLibevent { |
// Enables experimental TCP FastOpen option. |
bool use_tcp_fastopen_; |
+ // True when TCP FastOpen is in use and we have attempted the |
+ // connect with write. |
+ bool tcp_fastopen_write_attempted_; |
+ |
// True when TCP FastOpen is in use and we have done the connect. |
bool tcp_fastopen_connected_; |
- FastOpenStatus fast_open_status_; |
+ |
+ TCPFastOpenStatus tcp_fastopen_status_; |
bool logging_multiple_connect_attempts_; |