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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 // Handles packets for connection_ids in time wait state by discarding the 5 // Handles packets for connection_ids in time wait state by discarding the
6 // packet and sending the clients a public reset packet with exponential 6 // packet and sending the clients a public reset packet with exponential
7 // backoff. 7 // backoff.
8 8
9 #ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ 9 #ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
10 #define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ 10 #define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 // Called by the dispatcher when the underlying socket becomes writable again, 83 // Called by the dispatcher when the underlying socket becomes writable again,
84 // since we might need to send pending public reset packets which we didn't 84 // since we might need to send pending public reset packets which we didn't
85 // send because the underlying socket was write blocked. 85 // send because the underlying socket was write blocked.
86 void OnCanWrite() override; 86 void OnCanWrite() override;
87 87
88 // Used to delete connection_id entries that have outlived their time wait 88 // Used to delete connection_id entries that have outlived their time wait
89 // period. 89 // period.
90 void CleanUpOldConnectionIds(); 90 void CleanUpOldConnectionIds();
91 91
92 // If necessary, trims the oldest connections from the time-wait list until
93 // the size is under the configured maximum.
94 void TrimTimeWaitListIfNeeded();
95
92 // Given a ConnectionId that exists in the time wait list, returns the 96 // Given a ConnectionId that exists in the time wait list, returns the
93 // QuicVersion associated with it. 97 // QuicVersion associated with it.
94 QuicVersion GetQuicVersionFromConnectionId(QuicConnectionId connection_id); 98 QuicVersion GetQuicVersionFromConnectionId(QuicConnectionId connection_id);
95 99
96 // The number of connections on the time-wait list. 100 // The number of connections on the time-wait list.
97 size_t num_connections() const { return connection_id_map_.size(); } 101 size_t num_connections() const { return connection_id_map_.size(); }
98 102
99 protected: 103 protected:
100 virtual QuicEncryptedPacket* BuildPublicReset( 104 virtual QuicEncryptedPacket* BuildPublicReset(
101 const QuicPublicResetPacket& packet); 105 const QuicPublicResetPacket& packet);
(...skipping 20 matching lines...) Expand all
122 126
123 // Sends the packet out. Returns true if the packet was successfully consumed. 127 // Sends the packet out. Returns true if the packet was successfully consumed.
124 // If the writer got blocked and did not buffer the packet, we'll need to keep 128 // If the writer got blocked and did not buffer the packet, we'll need to keep
125 // the packet and retry sending. In case of all other errors we drop the 129 // the packet and retry sending. In case of all other errors we drop the
126 // packet. 130 // packet.
127 bool WriteToWire(QueuedPacket* packet); 131 bool WriteToWire(QueuedPacket* packet);
128 132
129 // Register the alarm with the epoll server to wake up at appropriate time. 133 // Register the alarm with the epoll server to wake up at appropriate time.
130 void SetConnectionIdCleanUpAlarm(); 134 void SetConnectionIdCleanUpAlarm();
131 135
136 // Removes the oldest connection from the time-wait list if it was added prior
137 // to "expiration_time". To unconditionally remove the oldest connection, use
138 // a QuicTime::Delta:Infinity(). This function modifies the
139 // connection_id_map_. If you plan to call this function in a loop, any
140 // iterators that you hold before the call to this function may be invalid
141 // afterward. Returns true if the oldest connection was expired. Returns
142 // false if the map is empty or the oldest connection has not expired.
143 bool MaybeExpireOldestConnection(QuicTime expiration_time);
144
132 // A map from a recently closed connection_id to the number of packets 145 // A map from a recently closed connection_id to the number of packets
133 // received after the termination of the connection bound to the 146 // received after the termination of the connection bound to the
134 // connection_id. 147 // connection_id.
135 struct ConnectionIdData { 148 struct ConnectionIdData {
136 ConnectionIdData(int num_packets_, 149 ConnectionIdData(int num_packets_,
137 QuicVersion version_, 150 QuicVersion version_,
138 QuicTime time_added_, 151 QuicTime time_added_,
139 QuicEncryptedPacket* close_packet) 152 QuicEncryptedPacket* close_packet)
140 : num_packets(num_packets_), 153 : num_packets(num_packets_),
141 version(version_), 154 version(version_),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // Interface that manages blocked writers. 188 // Interface that manages blocked writers.
176 QuicServerSessionVisitor* visitor_; 189 QuicServerSessionVisitor* visitor_;
177 190
178 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); 191 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager);
179 }; 192 };
180 193
181 } // namespace tools 194 } // namespace tools
182 } // namespace net 195 } // namespace net
183 196
184 #endif // NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ 197 #endif // NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698