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

Side by Side Diff: net/tools/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
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 "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"
(...skipping 10 matching lines...) Expand all
21 #include "net/tools/quic/quic_server_session.h" 21 #include "net/tools/quic/quic_server_session.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 namespace tools { 27 namespace tools {
28 28
29 namespace { 29 namespace {
30 30
31 // Time period for which the connection_id should live in time wait state.. 31 // Time period for which a given connection_id should live in the time-wait
32 const int kTimeWaitSeconds = 5; 32 // state.
33 int64 FLAGS_quic_time_wait_list_seconds = 5;
33 34
34 } // namespace 35 } // namespace
35 36
36 // A very simple alarm that just informs the QuicTimeWaitListManager to clean 37 // A very simple alarm that just informs the QuicTimeWaitListManager to clean
37 // up old connection_ids. This alarm should be unregistered and deleted before 38 // up old connection_ids. This alarm should be unregistered and deleted before
38 // the QuicTimeWaitListManager is deleted. 39 // the QuicTimeWaitListManager is deleted.
39 class ConnectionIdCleanUpAlarm : public EpollAlarm { 40 class ConnectionIdCleanUpAlarm : public EpollAlarm {
40 public: 41 public:
41 explicit ConnectionIdCleanUpAlarm( 42 explicit ConnectionIdCleanUpAlarm(
42 QuicTimeWaitListManager* time_wait_list_manager) 43 QuicTimeWaitListManager* time_wait_list_manager)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 84
84 DISALLOW_COPY_AND_ASSIGN(QueuedPacket); 85 DISALLOW_COPY_AND_ASSIGN(QueuedPacket);
85 }; 86 };
86 87
87 QuicTimeWaitListManager::QuicTimeWaitListManager( 88 QuicTimeWaitListManager::QuicTimeWaitListManager(
88 QuicPacketWriter* writer, 89 QuicPacketWriter* writer,
89 QuicServerSessionVisitor* visitor, 90 QuicServerSessionVisitor* visitor,
90 EpollServer* epoll_server, 91 EpollServer* epoll_server,
91 const QuicVersionVector& supported_versions) 92 const QuicVersionVector& supported_versions)
92 : epoll_server_(epoll_server), 93 : epoll_server_(epoll_server),
93 kTimeWaitPeriod_(QuicTime::Delta::FromSeconds(kTimeWaitSeconds)), 94 kTimeWaitPeriod_(
95 QuicTime::Delta::FromSeconds(FLAGS_quic_time_wait_list_seconds)),
94 connection_id_clean_up_alarm_(new ConnectionIdCleanUpAlarm(this)), 96 connection_id_clean_up_alarm_(new ConnectionIdCleanUpAlarm(this)),
95 clock_(epoll_server_), 97 clock_(epoll_server_),
96 writer_(writer), 98 writer_(writer),
97 visitor_(visitor) { 99 visitor_(visitor) {
98 SetConnectionIdCleanUpAlarm(); 100 SetConnectionIdCleanUpAlarm();
99 } 101 }
100 102
101 QuicTimeWaitListManager::~QuicTimeWaitListManager() { 103 QuicTimeWaitListManager::~QuicTimeWaitListManager() {
102 connection_id_clean_up_alarm_->UnregisterIfRegistered(); 104 connection_id_clean_up_alarm_->UnregisterIfRegistered();
103 STLDeleteElements(&pending_packets_queue_); 105 STLDeleteElements(&pending_packets_queue_);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 275
274 void QuicTimeWaitListManager::CleanUpOldConnectionIds() { 276 void QuicTimeWaitListManager::CleanUpOldConnectionIds() {
275 QuicTime now = clock_.ApproximateNow(); 277 QuicTime now = clock_.ApproximateNow();
276 while (!connection_id_map_.empty()) { 278 while (!connection_id_map_.empty()) {
277 ConnectionIdMap::iterator it = connection_id_map_.begin(); 279 ConnectionIdMap::iterator it = connection_id_map_.begin();
278 QuicTime oldest_connection_id = it->second.time_added; 280 QuicTime oldest_connection_id = it->second.time_added;
279 if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) { 281 if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) {
280 break; 282 break;
281 } 283 }
282 // This connection_id has lived its age, retire it now. 284 // This connection_id has lived its age, retire it now.
285 DVLOG(1) << "Retiring " << it->first << " from the time-wait state.";
283 delete it->second.close_packet; 286 delete it->second.close_packet;
284 connection_id_map_.erase(it); 287 connection_id_map_.erase(it);
285 } 288 }
286 SetConnectionIdCleanUpAlarm(); 289 SetConnectionIdCleanUpAlarm();
287 } 290 }
288 291
289 } // namespace tools 292 } // namespace tools
290 } // namespace net 293 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_spdy_client_stream_test.cc ('k') | net/tools/quic/test_tools/quic_test_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698