| OLD | NEW |
| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 return writer_->IsWriteBlockedDataBuffered(); | 254 return writer_->IsWriteBlockedDataBuffered(); |
| 255 } else if (result.status == WRITE_STATUS_ERROR) { | 255 } else if (result.status == WRITE_STATUS_ERROR) { |
| 256 LOG(WARNING) << "Received unknown error while sending reset packet to " | 256 LOG(WARNING) << "Received unknown error while sending reset packet to " |
| 257 << queued_packet->client_address().ToString() << ": " | 257 << queued_packet->client_address().ToString() << ": " |
| 258 << strerror(result.error_code); | 258 << strerror(result.error_code); |
| 259 } | 259 } |
| 260 return true; | 260 return true; |
| 261 } | 261 } |
| 262 | 262 |
| 263 void QuicTimeWaitListManager::SetConnectionIdCleanUpAlarm() { | 263 void QuicTimeWaitListManager::SetConnectionIdCleanUpAlarm() { |
| 264 connection_id_clean_up_alarm_->Cancel(); | |
| 265 QuicTime::Delta next_alarm_interval = QuicTime::Delta::Zero(); | 264 QuicTime::Delta next_alarm_interval = QuicTime::Delta::Zero(); |
| 266 if (!connection_id_map_.empty()) { | 265 if (!connection_id_map_.empty()) { |
| 267 QuicTime oldest_connection_id = | 266 QuicTime oldest_connection_id = |
| 268 connection_id_map_.begin()->second.time_added; | 267 connection_id_map_.begin()->second.time_added; |
| 269 QuicTime now = clock_->ApproximateNow(); | 268 QuicTime now = clock_->ApproximateNow(); |
| 270 if (now - oldest_connection_id < time_wait_period_) { | 269 if (now - oldest_connection_id < time_wait_period_) { |
| 271 next_alarm_interval = oldest_connection_id + time_wait_period_ - now; | 270 next_alarm_interval = oldest_connection_id + time_wait_period_ - now; |
| 272 } else { | 271 } else { |
| 273 LOG(ERROR) << "ConnectionId lingered for longer than time_wait_period_"; | 272 LOG(ERROR) << "ConnectionId lingered for longer than time_wait_period_"; |
| 274 } | 273 } |
| 275 } else { | 274 } else { |
| 276 // No connection_ids added so none will expire before time_wait_period_. | 275 // No connection_ids added so none will expire before time_wait_period_. |
| 277 next_alarm_interval = time_wait_period_; | 276 next_alarm_interval = time_wait_period_; |
| 278 } | 277 } |
| 279 | 278 |
| 280 connection_id_clean_up_alarm_->Set(clock_->ApproximateNow() + | 279 connection_id_clean_up_alarm_->Update( |
| 281 next_alarm_interval); | 280 clock_->ApproximateNow() + next_alarm_interval, QuicTime::Delta::Zero()); |
| 282 } | 281 } |
| 283 | 282 |
| 284 bool QuicTimeWaitListManager::MaybeExpireOldestConnection( | 283 bool QuicTimeWaitListManager::MaybeExpireOldestConnection( |
| 285 QuicTime expiration_time) { | 284 QuicTime expiration_time) { |
| 286 if (connection_id_map_.empty()) { | 285 if (connection_id_map_.empty()) { |
| 287 return false; | 286 return false; |
| 288 } | 287 } |
| 289 ConnectionIdMap::iterator it = connection_id_map_.begin(); | 288 ConnectionIdMap::iterator it = connection_id_map_.begin(); |
| 290 QuicTime oldest_connection_id_time = it->second.time_added; | 289 QuicTime oldest_connection_id_time = it->second.time_added; |
| 291 if (oldest_connection_id_time > expiration_time) { | 290 if (oldest_connection_id_time > expiration_time) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 version(version_), | 325 version(version_), |
| 327 time_added(time_added_), | 326 time_added(time_added_), |
| 328 connection_rejected_statelessly(connection_rejected_statelessly) {} | 327 connection_rejected_statelessly(connection_rejected_statelessly) {} |
| 329 | 328 |
| 330 QuicTimeWaitListManager::ConnectionIdData::ConnectionIdData( | 329 QuicTimeWaitListManager::ConnectionIdData::ConnectionIdData( |
| 331 ConnectionIdData&& other) = default; | 330 ConnectionIdData&& other) = default; |
| 332 | 331 |
| 333 QuicTimeWaitListManager::ConnectionIdData::~ConnectionIdData() {} | 332 QuicTimeWaitListManager::ConnectionIdData::~ConnectionIdData() {} |
| 334 | 333 |
| 335 } // namespace net | 334 } // namespace net |
| OLD | NEW |