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

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

Issue 786123002: Update from https://crrev.com/307330 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 277
276 void QuicTimeWaitListManager::CleanUpOldConnectionIds() { 278 void QuicTimeWaitListManager::CleanUpOldConnectionIds() {
277 QuicTime now = clock_.ApproximateNow(); 279 QuicTime now = clock_.ApproximateNow();
278 while (!connection_id_map_.empty()) { 280 while (!connection_id_map_.empty()) {
279 ConnectionIdMap::iterator it = connection_id_map_.begin(); 281 ConnectionIdMap::iterator it = connection_id_map_.begin();
280 QuicTime oldest_connection_id = it->second.time_added; 282 QuicTime oldest_connection_id = it->second.time_added;
281 if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) { 283 if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) {
282 break; 284 break;
283 } 285 }
284 // This connection_id has lived its age, retire it now. 286 // This connection_id has lived its age, retire it now.
287 DVLOG(1) << "Retiring " << it->first << " from the time-wait state.";
285 delete it->second.close_packet; 288 delete it->second.close_packet;
286 connection_id_map_.erase(it); 289 connection_id_map_.erase(it);
287 } 290 }
288 SetConnectionIdCleanUpAlarm(); 291 SetConnectionIdCleanUpAlarm();
289 } 292 }
290 293
291 } // namespace tools 294 } // namespace tools
292 } // namespace net 295 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_spdy_server_stream.h ('k') | net/tools/quic/test_tools/packet_dropping_test_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698