Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(917)

Unified Diff: net/socket/tcp_socket_libevent.h

Issue 583883002: Adds TCP FastOpen blackhole recovery code to avoid getting persistently blackholed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits addressed and histogram updated. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/socket/tcp_socket_libevent.cc » ('j') | net/socket/tcp_socket_libevent.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_socket_libevent.h
diff --git a/net/socket/tcp_socket_libevent.h b/net/socket/tcp_socket_libevent.h
index 89b6a22bdd08d24b05529b6a9f2031351098d256..69a40c091f657410b946f847be1295878943aefc 100644
--- a/net/socket/tcp_socket_libevent.h
+++ b/net/socket/tcp_socket_libevent.h
@@ -87,53 +87,67 @@ class NET_EXPORT TCPSocketLibevent {
const BoundNetLog& net_log() const { return net_log_; }
private:
- // States that a fast open socket attempt can result in.
- enum FastOpenStatus {
- FAST_OPEN_STATUS_UNKNOWN,
+ // States that a FastOpen socket attempt can result in.
+ enum TCPFastOpenStatus {
+ TCP_FASTOPEN_STATUS_UNKNOWN,
- // The initial fast open 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 fast open 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
- // fast open would have worked.
- FAST_OPEN_ERROR,
+ // FastOpen would have worked.
+ TCP_FASTOPEN_ERROR,
- // An attempt to do a fast open 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 fast open 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 fast open succeeded immediately
- // (FAST_OPEN_FAST_CONNECT_RETURN) and our probe to determine if the
- // socket was using fast open 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 fast open 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 fast open 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 fast open 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,
+ TCP_FASTOPEN_NO_SYN_DATA_GETSOCKOPT_FAILED,
- FAST_OPEN_MAX_VALUE
+ // 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.)
+ TCP_FASTOPEN_PREVIOUSLY_FAILED,
+
+ TCP_FASTOPEN_MAX_VALUE
};
void AcceptCompleted(scoped_ptr<TCPSocketLibevent>* tcp_socket,
@@ -158,14 +172,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 +187,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_;
« no previous file with comments | « no previous file | net/socket/tcp_socket_libevent.cc » ('j') | net/socket/tcp_socket_libevent.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698