OLD | NEW |
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 // 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_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 9 #ifndef NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
10 #define NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 10 #define NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 // Called by the dispatcher when the underlying socket becomes writable again, | 79 // Called by the dispatcher when the underlying socket becomes writable again, |
80 // since we might need to send pending public reset packets which we didn't | 80 // since we might need to send pending public reset packets which we didn't |
81 // send because the underlying socket was write blocked. | 81 // send because the underlying socket was write blocked. |
82 void OnCanWrite() override; | 82 void OnCanWrite() override; |
83 | 83 |
84 // Used to delete connection_id entries that have outlived their time wait | 84 // Used to delete connection_id entries that have outlived their time wait |
85 // period. | 85 // period. |
86 void CleanUpOldConnectionIds(); | 86 void CleanUpOldConnectionIds(); |
87 | 87 |
| 88 // If necessary, trims the oldest connections from the time-wait list until |
| 89 // the size is under the configured maximum. |
| 90 void TrimTimeWaitListIfNeeded(); |
| 91 |
88 // Given a ConnectionId that exists in the time wait list, returns the | 92 // Given a ConnectionId that exists in the time wait list, returns the |
89 // QuicVersion associated with it. | 93 // QuicVersion associated with it. |
90 QuicVersion GetQuicVersionFromConnectionId(QuicConnectionId connection_id); | 94 QuicVersion GetQuicVersionFromConnectionId(QuicConnectionId connection_id); |
91 | 95 |
92 // The number of connections on the time-wait list. | 96 // The number of connections on the time-wait list. |
93 size_t num_connections() const { return connection_id_map_.size(); } | 97 size_t num_connections() const { return connection_id_map_.size(); } |
94 | 98 |
95 protected: | 99 protected: |
96 virtual QuicEncryptedPacket* BuildPublicReset( | 100 virtual QuicEncryptedPacket* BuildPublicReset( |
97 const QuicPublicResetPacket& packet); | 101 const QuicPublicResetPacket& packet); |
(...skipping 20 matching lines...) Expand all Loading... |
118 | 122 |
119 // Sends the packet out. Returns true if the packet was successfully consumed. | 123 // Sends the packet out. Returns true if the packet was successfully consumed. |
120 // If the writer got blocked and did not buffer the packet, we'll need to keep | 124 // If the writer got blocked and did not buffer the packet, we'll need to keep |
121 // the packet and retry sending. In case of all other errors we drop the | 125 // the packet and retry sending. In case of all other errors we drop the |
122 // packet. | 126 // packet. |
123 bool WriteToWire(QueuedPacket* packet); | 127 bool WriteToWire(QueuedPacket* packet); |
124 | 128 |
125 // Register the alarm to wake up at appropriate time. | 129 // Register the alarm to wake up at appropriate time. |
126 void SetConnectionIdCleanUpAlarm(); | 130 void SetConnectionIdCleanUpAlarm(); |
127 | 131 |
| 132 // Removes the oldest connection from the time-wait list if it was added prior |
| 133 // to "expiration_time". To unconditionally remove the oldest connection, use |
| 134 // a QuicTime::Delta:Infinity(). This function modifies the |
| 135 // connection_id_map_. If you plan to call this function in a loop, any |
| 136 // iterators that you hold before the call to this function may be invalid |
| 137 // afterward. Returns true if the oldest connection was expired. Returns |
| 138 // false if the map is empty or the oldest connection has not expired. |
| 139 bool MaybeExpireOldestConnection(QuicTime expiration_time); |
| 140 |
128 // A map from a recently closed connection_id to the number of packets | 141 // A map from a recently closed connection_id to the number of packets |
129 // received after the termination of the connection bound to the | 142 // received after the termination of the connection bound to the |
130 // connection_id. | 143 // connection_id. |
131 struct ConnectionIdData { | 144 struct ConnectionIdData { |
132 ConnectionIdData(int num_packets_, | 145 ConnectionIdData(int num_packets_, |
133 QuicVersion version_, | 146 QuicVersion version_, |
134 QuicTime time_added_, | 147 QuicTime time_added_, |
135 QuicEncryptedPacket* close_packet) | 148 QuicEncryptedPacket* close_packet) |
136 : num_packets(num_packets_), | 149 : num_packets(num_packets_), |
137 version(version_), | 150 version(version_), |
(...skipping 30 matching lines...) Expand all Loading... |
168 | 181 |
169 // Interface that manages blocked writers. | 182 // Interface that manages blocked writers. |
170 QuicServerSessionVisitor* visitor_; | 183 QuicServerSessionVisitor* visitor_; |
171 | 184 |
172 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); | 185 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); |
173 }; | 186 }; |
174 | 187 |
175 } // namespace net | 188 } // namespace net |
176 | 189 |
177 #endif // NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 190 #endif // NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
OLD | NEW |