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

Side by Side 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: "Streamlined logic for when RecordTCPFastOpenStatus is called (and other nits.)" 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/socket/tcp_socket_libevent.cc » ('j') | net/socket/tcp_socket_libevent.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ 5 #ifndef NET_SOCKET_TCP_SOCKET_LIBEVENT_H_
6 #define NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ 6 #define NET_SOCKET_TCP_SOCKET_LIBEVENT_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // 81 //
82 // TODO(yzshen): Change logging format and let TCPClientSocket log the 82 // TODO(yzshen): Change logging format and let TCPClientSocket log the
83 // start/end of a series of connect attempts itself. 83 // start/end of a series of connect attempts itself.
84 void StartLoggingMultipleConnectAttempts(const AddressList& addresses); 84 void StartLoggingMultipleConnectAttempts(const AddressList& addresses);
85 void EndLoggingMultipleConnectAttempts(int net_error); 85 void EndLoggingMultipleConnectAttempts(int net_error);
86 86
87 const BoundNetLog& net_log() const { return net_log_; } 87 const BoundNetLog& net_log() const { return net_log_; }
88 88
89 private: 89 private:
90 // States that a fast open socket attempt can result in. 90 // States that a fast open socket attempt can result in.
91 enum FastOpenStatus { 91 enum TCPFastOpenStatus {
92 FAST_OPEN_STATUS_UNKNOWN, 92 TCP_FASTOPEN_STATUS_UNKNOWN,
93 93
94 // The initial fast open connect attempted returned synchronously, 94 // The initial fast open connect attempted returned synchronously,
95 // indicating that we had and sent a cookie along with the initial data. 95 // indicating that we had and sent a cookie along with the initial data.
96 FAST_OPEN_FAST_CONNECT_RETURN, 96 TCP_FASTOPEN_FAST_CONNECT_RETURN,
97 97
98 // The initial fast open connect attempted returned asynchronously, 98 // The initial fast open connect attempted returned asynchronously,
99 // indicating that we did not have a cookie for the server. 99 // indicating that we did not have a cookie for the server.
100 FAST_OPEN_SLOW_CONNECT_RETURN, 100 TCP_FASTOPEN_SLOW_CONNECT_RETURN,
101 101
102 // Some other error occurred on connection, so we couldn't tell if 102 // Some other error occurred on connection, so we couldn't tell if
103 // fast open would have worked. 103 // fast open would have worked.
104 FAST_OPEN_ERROR, 104 TCP_FASTOPEN_ERROR,
105 105
106 // An attempt to do a fast open succeeded immediately 106 // An attempt to do a fast open succeeded immediately
107 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server 107 // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and we later confirmed that the server
108 // had acked the data we sent. 108 // had acked the data we sent.
109 FAST_OPEN_SYN_DATA_ACK, 109 TCP_FASTOPEN_SYN_DATA_ACK,
110 110
111 // An attempt to do a fast open succeeded immediately 111 // An attempt to do a fast open succeeded immediately
112 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server 112 // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and we later confirmed that the server
113 // had nacked the data we sent. 113 // had nacked the data we sent.
114 FAST_OPEN_SYN_DATA_NACK, 114 TCP_FASTOPEN_SYN_DATA_NACK,
115 115
116 // An attempt to do a fast open succeeded immediately 116 // An attempt to do a fast open succeeded immediately
117 // (FAST_OPEN_FAST_CONNECT_RETURN) and our probe to determine if the 117 // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and our probe to determine if the
118 // socket was using fast open failed. 118 // socket was using fast open failed.
119 FAST_OPEN_SYN_DATA_FAILED, 119 TCP_FASTOPEN_SYN_DATA_GETSOCKOPT_FAILED,
120 120
121 // An attempt to do a fast open failed (FAST_OPEN_SLOW_CONNECT_RETURN) 121 // An attempt to do a fast open failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN)
122 // and we later confirmed that the server had acked initial data. This 122 // and we later confirmed that the server had acked initial data. This
123 // should never happen (we didn't send data, so it shouldn't have 123 // should never happen (we didn't send data, so it shouldn't have
124 // been acked). 124 // been acked).
125 FAST_OPEN_NO_SYN_DATA_ACK, 125 TCP_FASTOPEN_NO_SYN_DATA_ACK,
126 126
127 // An attempt to do a fast open failed (FAST_OPEN_SLOW_CONNECT_RETURN) 127 // An attempt to do a fast open failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN)
128 // and we later discovered that the server had nacked initial data. This 128 // and we later discovered that the server had nacked initial data. This
129 // is the expected case results for FAST_OPEN_SLOW_CONNECT_RETURN. 129 // is the expected case results for TCP_FASTOPEN_SLOW_CONNECT_RETURN.
130 FAST_OPEN_NO_SYN_DATA_NACK, 130 TCP_FASTOPEN_NO_SYN_DATA_NACK,
131 131
132 // An attempt to do a fast open failed (FAST_OPEN_SLOW_CONNECT_RETURN) 132 // An attempt to do a fast open failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN)
133 // and our later probe for ack/nack state failed. 133 // and our later probe for ack/nack state failed.
134 FAST_OPEN_NO_SYN_DATA_FAILED, 134 TCP_FASTOPEN_NO_SYN_DATA_GETSOCKOPT_FAILED,
135 135
136 FAST_OPEN_MAX_VALUE 136 // The initial fast open connect succeeded immediately
137 // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and a subsequent attempt to read from
138 // the connection resulted in failure.
139 TCP_FASTOPEN_FAST_CONNECT_FAILED,
140
141 // The initial fast open connect failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN)
142 // and a subsequent attempt to read from the connection resulted in failure.
143 TCP_FASTOPEN_SLOW_CONNECT_FAILED,
144
145 TCP_FASTOPEN_MAX_VALUE
mmenke 2014/09/24 14:46:11 One high level question... How do you intend to l
Jana 2014/09/25 16:10:16 This is a good point. I thought about this a while
137 }; 146 };
138 147
139 void AcceptCompleted(scoped_ptr<TCPSocketLibevent>* tcp_socket, 148 void AcceptCompleted(scoped_ptr<TCPSocketLibevent>* tcp_socket,
140 IPEndPoint* address, 149 IPEndPoint* address,
141 const CompletionCallback& callback, 150 const CompletionCallback& callback,
142 int rv); 151 int rv);
143 int HandleAcceptCompleted(scoped_ptr<TCPSocketLibevent>* tcp_socket, 152 int HandleAcceptCompleted(scoped_ptr<TCPSocketLibevent>* tcp_socket,
144 IPEndPoint* address, 153 IPEndPoint* address,
145 int rv); 154 int rv);
146 int BuildTcpSocketLibevent(scoped_ptr<TCPSocketLibevent>* tcp_socket, 155 int BuildTcpSocketLibevent(scoped_ptr<TCPSocketLibevent>* tcp_socket,
147 IPEndPoint* address); 156 IPEndPoint* address);
148 157
149 void ConnectCompleted(const CompletionCallback& callback, int rv) const; 158 void ConnectCompleted(const CompletionCallback& callback, int rv) const;
150 int HandleConnectCompleted(int rv) const; 159 int HandleConnectCompleted(int rv) const;
151 void LogConnectBegin(const AddressList& addresses) const; 160 void LogConnectBegin(const AddressList& addresses) const;
152 void LogConnectEnd(int net_error) const; 161 void LogConnectEnd(int net_error) const;
153 162
154 void ReadCompleted(const scoped_refptr<IOBuffer>& buf, 163 void ReadCompleted(const scoped_refptr<IOBuffer>& buf,
155 const CompletionCallback& callback, 164 const CompletionCallback& callback,
156 int rv); 165 int rv);
157 int HandleReadCompleted(IOBuffer* buf, int rv); 166 int HandleReadCompleted(IOBuffer* buf, int rv);
158 167
159 void WriteCompleted(const scoped_refptr<IOBuffer>& buf, 168 void WriteCompleted(const scoped_refptr<IOBuffer>& buf,
160 const CompletionCallback& callback, 169 const CompletionCallback& callback,
161 int rv) const; 170 int rv);
162 int HandleWriteCompleted(IOBuffer* buf, int rv) const; 171 int HandleWriteCompleted(IOBuffer* buf, int rv);
163 int TcpFastOpenWrite(IOBuffer* buf, 172 int TcpFastOpenWrite(IOBuffer* buf,
164 int buf_len, 173 int buf_len,
165 const CompletionCallback& callback); 174 const CompletionCallback& callback);
166 175
167 // Called when the socket is known to be in a connected state. 176 // Called when the socket is known to be in a connected state.
168 void RecordFastOpenStatus(); 177 void RecordTCPFastOpenStatus();
169 178
170 scoped_ptr<SocketLibevent> socket_; 179 scoped_ptr<SocketLibevent> socket_;
171 scoped_ptr<SocketLibevent> accept_socket_; 180 scoped_ptr<SocketLibevent> accept_socket_;
172 181
173 // Enables experimental TCP FastOpen option. 182 // Enables experimental TCP FastOpen option.
174 bool use_tcp_fastopen_; 183 bool use_tcp_fastopen_;
175 184
185 // True when TCP FastOpen is in use and we have attempted the
186 // connect with write.
187 bool tcp_fastopen_write_attempted_;
188
176 // True when TCP FastOpen is in use and we have done the connect. 189 // True when TCP FastOpen is in use and we have done the connect.
177 bool tcp_fastopen_connected_; 190 bool tcp_fastopen_connected_;
178 FastOpenStatus fast_open_status_; 191
192 TCPFastOpenStatus tcp_fastopen_status_;
179 193
180 bool logging_multiple_connect_attempts_; 194 bool logging_multiple_connect_attempts_;
181 195
182 BoundNetLog net_log_; 196 BoundNetLog net_log_;
183 197
184 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent); 198 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent);
185 }; 199 };
186 200
187 } // namespace net 201 } // namespace net
188 202
189 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ 203 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_
OLDNEW
« 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