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

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

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « net/quic/quic_stream_factory_test.cc ('k') | net/quic/quic_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/quic/quic_time_wait_list_manager.h" 5 #include "net/quic/quic_time_wait_list_manager.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "net/base/ip_endpoint.h" 12 #include "net/base/ip_endpoint.h"
13 #include "net/quic/crypto/crypto_protocol.h" 13 #include "net/quic/crypto/crypto_protocol.h"
14 #include "net/quic/crypto/quic_decrypter.h" 14 #include "net/quic/crypto/quic_decrypter.h"
15 #include "net/quic/crypto/quic_encrypter.h" 15 #include "net/quic/crypto/quic_encrypter.h"
16 #include "net/quic/quic_clock.h" 16 #include "net/quic/quic_clock.h"
17 #include "net/quic/quic_connection_helper.h" 17 #include "net/quic/quic_connection_helper.h"
18 #include "net/quic/quic_framer.h" 18 #include "net/quic/quic_framer.h"
19 #include "net/quic/quic_protocol.h" 19 #include "net/quic/quic_protocol.h"
20 #include "net/quic/quic_server_session.h" 20 #include "net/quic/quic_server_session.h"
21 #include "net/quic/quic_utils.h" 21 #include "net/quic/quic_utils.h"
22 22
23 using base::StringPiece; 23 using base::StringPiece;
24 using std::make_pair; 24 using std::make_pair;
25 25
26 namespace net { 26 namespace net {
27 27
28 namespace { 28 namespace {
29 29
30 // Time period for which the connection_id should live in time wait state.. 30 // Time period for which a given connection_id should live in the time-wait
31 const int kTimeWaitSeconds = 5; 31 // state.
32 int64 FLAGS_quic_time_wait_list_seconds = 5;
32 33
33 } // namespace 34 } // namespace
34 35
35 // A very simple alarm that just informs the QuicTimeWaitListManager to clean 36 // A very simple alarm that just informs the QuicTimeWaitListManager to clean
36 // up old connection_ids. This alarm should be unregistered and deleted before 37 // up old connection_ids. This alarm should be unregistered and deleted before
37 // the QuicTimeWaitListManager is deleted. 38 // the QuicTimeWaitListManager is deleted.
38 class ConnectionIdCleanUpAlarm : public QuicAlarm::Delegate { 39 class ConnectionIdCleanUpAlarm : public QuicAlarm::Delegate {
39 public: 40 public:
40 explicit ConnectionIdCleanUpAlarm( 41 explicit ConnectionIdCleanUpAlarm(
41 QuicTimeWaitListManager* time_wait_list_manager) 42 QuicTimeWaitListManager* time_wait_list_manager)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 80
80 DISALLOW_COPY_AND_ASSIGN(QueuedPacket); 81 DISALLOW_COPY_AND_ASSIGN(QueuedPacket);
81 }; 82 };
82 83
83 QuicTimeWaitListManager::QuicTimeWaitListManager( 84 QuicTimeWaitListManager::QuicTimeWaitListManager(
84 QuicPacketWriter* writer, 85 QuicPacketWriter* writer,
85 QuicServerSessionVisitor* visitor, 86 QuicServerSessionVisitor* visitor,
86 QuicConnectionHelperInterface* helper, 87 QuicConnectionHelperInterface* helper,
87 const QuicVersionVector& supported_versions) 88 const QuicVersionVector& supported_versions)
88 : helper_(helper), 89 : helper_(helper),
89 kTimeWaitPeriod_(QuicTime::Delta::FromSeconds(kTimeWaitSeconds)), 90 kTimeWaitPeriod_(
91 QuicTime::Delta::FromSeconds(FLAGS_quic_time_wait_list_seconds)),
90 connection_id_clean_up_alarm_( 92 connection_id_clean_up_alarm_(
91 helper_->CreateAlarm(new ConnectionIdCleanUpAlarm(this))), 93 helper_->CreateAlarm(new ConnectionIdCleanUpAlarm(this))),
92 writer_(writer), 94 writer_(writer),
93 visitor_(visitor) { 95 visitor_(visitor) {
94 SetConnectionIdCleanUpAlarm(); 96 SetConnectionIdCleanUpAlarm();
95 } 97 }
96 98
97 QuicTimeWaitListManager::~QuicTimeWaitListManager() { 99 QuicTimeWaitListManager::~QuicTimeWaitListManager() {
98 connection_id_clean_up_alarm_->Cancel(); 100 connection_id_clean_up_alarm_->Cancel();
99 STLDeleteElements(&pending_packets_queue_); 101 STLDeleteElements(&pending_packets_queue_);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 269
268 void QuicTimeWaitListManager::CleanUpOldConnectionIds() { 270 void QuicTimeWaitListManager::CleanUpOldConnectionIds() {
269 QuicTime now = helper_->GetClock()->ApproximateNow(); 271 QuicTime now = helper_->GetClock()->ApproximateNow();
270 while (!connection_id_map_.empty()) { 272 while (!connection_id_map_.empty()) {
271 ConnectionIdMap::iterator it = connection_id_map_.begin(); 273 ConnectionIdMap::iterator it = connection_id_map_.begin();
272 QuicTime oldest_connection_id = it->second.time_added; 274 QuicTime oldest_connection_id = it->second.time_added;
273 if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) { 275 if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) {
274 break; 276 break;
275 } 277 }
276 // This connection_id has lived its age, retire it now. 278 // This connection_id has lived its age, retire it now.
279 DVLOG(1) << "Retiring " << it->first << " from the time-wait state.";
277 delete it->second.close_packet; 280 delete it->second.close_packet;
278 connection_id_map_.erase(it); 281 connection_id_map_.erase(it);
279 } 282 }
280 SetConnectionIdCleanUpAlarm(); 283 SetConnectionIdCleanUpAlarm();
281 } 284 }
282 285
283 } // namespace net 286 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory_test.cc ('k') | net/quic/quic_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698