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

Side by Side Diff: net/tools/quic/quic_time_wait_list_manager.cc

Issue 2631613002: Revert of Add quic_logging (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "net/tools/quic/quic_time_wait_list_manager.h" 5 #include "net/tools/quic/quic_time_wait_list_manager.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/logging.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "net/quic/core/crypto/crypto_protocol.h" 15 #include "net/quic/core/crypto/crypto_protocol.h"
15 #include "net/quic/core/crypto/quic_decrypter.h" 16 #include "net/quic/core/crypto/quic_decrypter.h"
16 #include "net/quic/core/crypto/quic_encrypter.h" 17 #include "net/quic/core/crypto/quic_encrypter.h"
17 #include "net/quic/core/quic_flags.h" 18 #include "net/quic/core/quic_flags.h"
18 #include "net/quic/core/quic_framer.h" 19 #include "net/quic/core/quic_framer.h"
19 #include "net/quic/core/quic_packets.h" 20 #include "net/quic/core/quic_packets.h"
20 #include "net/quic/core/quic_server_session_base.h" 21 #include "net/quic/core/quic_server_session_base.h"
21 #include "net/quic/core/quic_utils.h" 22 #include "net/quic/core/quic_utils.h"
22 #include "net/quic/platform/api/quic_clock.h" 23 #include "net/quic/platform/api/quic_clock.h"
23 #include "net/quic/platform/api/quic_logging.h"
24 #include "net/quic/platform/api/quic_socket_address.h" 24 #include "net/quic/platform/api/quic_socket_address.h"
25 25
26 using base::StringPiece; 26 using base::StringPiece;
27 27
28 namespace net { 28 namespace net {
29 29
30 // A very simple alarm that just informs the QuicTimeWaitListManager to clean 30 // A very simple alarm that just informs the QuicTimeWaitListManager to clean
31 // up old connection_ids. This alarm should be cancelled and deleted before 31 // up old connection_ids. This alarm should be cancelled and deleted before
32 // the QuicTimeWaitListManager is deleted. 32 // the QuicTimeWaitListManager is deleted.
33 class ConnectionIdCleanUpAlarm : public QuicAlarm::Delegate { 33 class ConnectionIdCleanUpAlarm : public QuicAlarm::Delegate {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 } 148 }
149 149
150 void QuicTimeWaitListManager::ProcessPacket( 150 void QuicTimeWaitListManager::ProcessPacket(
151 const QuicSocketAddress& server_address, 151 const QuicSocketAddress& server_address,
152 const QuicSocketAddress& client_address, 152 const QuicSocketAddress& client_address,
153 QuicConnectionId connection_id, 153 QuicConnectionId connection_id,
154 QuicPacketNumber packet_number, 154 QuicPacketNumber packet_number,
155 const QuicEncryptedPacket& /*packet*/) { 155 const QuicEncryptedPacket& /*packet*/) {
156 DCHECK(IsConnectionIdInTimeWait(connection_id)); 156 DCHECK(IsConnectionIdInTimeWait(connection_id));
157 QUIC_DLOG(INFO) << "Processing " << connection_id << " in time wait state."; 157 DVLOG(1) << "Processing " << connection_id << " in time wait state.";
158 // TODO(satyamshekhar): Think about handling packets from different client 158 // TODO(satyamshekhar): Think about handling packets from different client
159 // addresses. 159 // addresses.
160 ConnectionIdMap::iterator it = connection_id_map_.find(connection_id); 160 ConnectionIdMap::iterator it = connection_id_map_.find(connection_id);
161 DCHECK(it != connection_id_map_.end()); 161 DCHECK(it != connection_id_map_.end());
162 // Increment the received packet count. 162 // Increment the received packet count.
163 ConnectionIdData* connection_data = &it->second; 163 ConnectionIdData* connection_data = &it->second;
164 ++(connection_data->num_packets); 164 ++(connection_data->num_packets);
165 165
166 if (!ShouldSendResponse(connection_data->num_packets)) { 166 if (!ShouldSendResponse(connection_data->num_packets)) {
167 return; 167 return;
168 } 168 }
169 169
170 if (!connection_data->termination_packets.empty()) { 170 if (!connection_data->termination_packets.empty()) {
171 if (connection_data->connection_rejected_statelessly) { 171 if (connection_data->connection_rejected_statelessly) {
172 QUIC_DVLOG(3) 172 DVLOG(3) << "Time wait list sending previous stateless reject response "
173 << "Time wait list sending previous stateless reject response " 173 << "for connection " << connection_id;
174 << "for connection " << connection_id;
175 } 174 }
176 for (const auto& packet : connection_data->termination_packets) { 175 for (const auto& packet : connection_data->termination_packets) {
177 SendOrQueuePacket(base::MakeUnique<QueuedPacket>( 176 SendOrQueuePacket(base::MakeUnique<QueuedPacket>(
178 server_address, client_address, packet->Clone())); 177 server_address, client_address, packet->Clone()));
179 } 178 }
180 return; 179 return;
181 } 180 }
182 181
183 SendPublicReset(server_address, client_address, connection_id, packet_number); 182 SendPublicReset(server_address, client_address, connection_id, packet_number);
184 } 183 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 WriteResult result = writer_->WritePacket( 241 WriteResult result = writer_->WritePacket(
243 queued_packet->packet()->data(), queued_packet->packet()->length(), 242 queued_packet->packet()->data(), queued_packet->packet()->length(),
244 queued_packet->server_address().host(), queued_packet->client_address(), 243 queued_packet->server_address().host(), queued_packet->client_address(),
245 nullptr); 244 nullptr);
246 if (result.status == WRITE_STATUS_BLOCKED) { 245 if (result.status == WRITE_STATUS_BLOCKED) {
247 // If blocked and unbuffered, return false to retry sending. 246 // If blocked and unbuffered, return false to retry sending.
248 DCHECK(writer_->IsWriteBlocked()); 247 DCHECK(writer_->IsWriteBlocked());
249 visitor_->OnWriteBlocked(this); 248 visitor_->OnWriteBlocked(this);
250 return writer_->IsWriteBlockedDataBuffered(); 249 return writer_->IsWriteBlockedDataBuffered();
251 } else if (result.status == WRITE_STATUS_ERROR) { 250 } else if (result.status == WRITE_STATUS_ERROR) {
252 QUIC_LOG_FIRST_N(WARNING, 1) 251 LOG(WARNING) << "Received unknown error while sending reset packet to "
253 << "Received unknown error while sending reset packet to " 252 << queued_packet->client_address().ToString() << ": "
254 << queued_packet->client_address().ToString() << ": " 253 << strerror(result.error_code);
255 << strerror(result.error_code);
256 } 254 }
257 return true; 255 return true;
258 } 256 }
259 257
260 void QuicTimeWaitListManager::SetConnectionIdCleanUpAlarm() { 258 void QuicTimeWaitListManager::SetConnectionIdCleanUpAlarm() {
261 QuicTime::Delta next_alarm_interval = QuicTime::Delta::Zero(); 259 QuicTime::Delta next_alarm_interval = QuicTime::Delta::Zero();
262 if (!connection_id_map_.empty()) { 260 if (!connection_id_map_.empty()) {
263 QuicTime oldest_connection_id = 261 QuicTime oldest_connection_id =
264 connection_id_map_.begin()->second.time_added; 262 connection_id_map_.begin()->second.time_added;
265 QuicTime now = clock_->ApproximateNow(); 263 QuicTime now = clock_->ApproximateNow();
266 if (now - oldest_connection_id < time_wait_period_) { 264 if (now - oldest_connection_id < time_wait_period_) {
267 next_alarm_interval = oldest_connection_id + time_wait_period_ - now; 265 next_alarm_interval = oldest_connection_id + time_wait_period_ - now;
268 } else { 266 } else {
269 QUIC_LOG(ERROR) 267 LOG(ERROR) << "ConnectionId lingered for longer than time_wait_period_";
270 << "ConnectionId lingered for longer than time_wait_period_";
271 } 268 }
272 } else { 269 } else {
273 // No connection_ids added so none will expire before time_wait_period_. 270 // No connection_ids added so none will expire before time_wait_period_.
274 next_alarm_interval = time_wait_period_; 271 next_alarm_interval = time_wait_period_;
275 } 272 }
276 273
277 connection_id_clean_up_alarm_->Update( 274 connection_id_clean_up_alarm_->Update(
278 clock_->ApproximateNow() + next_alarm_interval, QuicTime::Delta::Zero()); 275 clock_->ApproximateNow() + next_alarm_interval, QuicTime::Delta::Zero());
279 } 276 }
280 277
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 version(version_), 320 version(version_),
324 time_added(time_added_), 321 time_added(time_added_),
325 connection_rejected_statelessly(connection_rejected_statelessly) {} 322 connection_rejected_statelessly(connection_rejected_statelessly) {}
326 323
327 QuicTimeWaitListManager::ConnectionIdData::ConnectionIdData( 324 QuicTimeWaitListManager::ConnectionIdData::ConnectionIdData(
328 ConnectionIdData&& other) = default; 325 ConnectionIdData&& other) = default;
329 326
330 QuicTimeWaitListManager::ConnectionIdData::~ConnectionIdData() {} 327 QuicTimeWaitListManager::ConnectionIdData::~ConnectionIdData() {}
331 328
332 } // namespace net 329 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_spdy_server_stream_base.cc ('k') | net/tools/quic/stateless_rejector_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698