| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "net/quic/crypto/crypto_protocol.h" | 10 #include "net/quic/crypto/crypto_protocol.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 epoll_server_.set_now_in_usec(time_wait_period.ToMicroseconds()); | 346 epoll_server_.set_now_in_usec(time_wait_period.ToMicroseconds()); |
| 347 for (size_t connection_id = kOldConnectionIdCount + 1; | 347 for (size_t connection_id = kOldConnectionIdCount + 1; |
| 348 connection_id <= kConnectionIdCount; ++connection_id) { | 348 connection_id <= kConnectionIdCount; ++connection_id) { |
| 349 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id)); | 349 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id)); |
| 350 AddConnectionId(connection_id); | 350 AddConnectionId(connection_id); |
| 351 } | 351 } |
| 352 EXPECT_EQ(kConnectionIdCount, time_wait_list_manager_.num_connections()); | 352 EXPECT_EQ(kConnectionIdCount, time_wait_list_manager_.num_connections()); |
| 353 | 353 |
| 354 QuicTime::Delta offset = QuicTime::Delta::FromMicroseconds(39); | 354 QuicTime::Delta offset = QuicTime::Delta::FromMicroseconds(39); |
| 355 // Now set the current time as time_wait_period + offset usecs. | 355 // Now set the current time as time_wait_period + offset usecs. |
| 356 epoll_server_.set_now_in_usec(time_wait_period.Add(offset).ToMicroseconds()); | 356 epoll_server_.set_now_in_usec((time_wait_period + offset).ToMicroseconds()); |
| 357 // After all the old connection_ids are cleaned up, check the next alarm | 357 // After all the old connection_ids are cleaned up, check the next alarm |
| 358 // interval. | 358 // interval. |
| 359 int64_t next_alarm_time = epoll_server_.ApproximateNowInUsec() + | 359 int64_t next_alarm_time = epoll_server_.ApproximateNowInUsec() + |
| 360 time_wait_period.Subtract(offset).ToMicroseconds(); | 360 (time_wait_period - offset).ToMicroseconds(); |
| 361 EXPECT_CALL(epoll_server_, RegisterAlarm(next_alarm_time, _)); | 361 EXPECT_CALL(epoll_server_, RegisterAlarm(next_alarm_time, _)); |
| 362 | 362 |
| 363 time_wait_list_manager_.CleanUpOldConnectionIds(); | 363 time_wait_list_manager_.CleanUpOldConnectionIds(); |
| 364 for (size_t connection_id = 1; connection_id <= kConnectionIdCount; | 364 for (size_t connection_id = 1; connection_id <= kConnectionIdCount; |
| 365 ++connection_id) { | 365 ++connection_id) { |
| 366 EXPECT_EQ(connection_id > kOldConnectionIdCount, | 366 EXPECT_EQ(connection_id > kOldConnectionIdCount, |
| 367 IsConnectionIdInTimeWait(connection_id)) | 367 IsConnectionIdInTimeWait(connection_id)) |
| 368 << "kOldConnectionIdCount: " << kOldConnectionIdCount | 368 << "kOldConnectionIdCount: " << kOldConnectionIdCount |
| 369 << " connection_id: " << connection_id; | 369 << " connection_id: " << connection_id; |
| 370 } | 370 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1))); | 472 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1))); |
| 473 | 473 |
| 474 const int kRandomSequenceNumber = 1; | 474 const int kRandomSequenceNumber = 1; |
| 475 ProcessPacket(connection_id_, kRandomSequenceNumber); | 475 ProcessPacket(connection_id_, kRandomSequenceNumber); |
| 476 | 476 |
| 477 const QuicTime::Delta time_wait_period = | 477 const QuicTime::Delta time_wait_period = |
| 478 QuicTimeWaitListManagerPeer::time_wait_period(&time_wait_list_manager_); | 478 QuicTimeWaitListManagerPeer::time_wait_period(&time_wait_list_manager_); |
| 479 | 479 |
| 480 QuicTime::Delta offset = QuicTime::Delta::FromMicroseconds(39); | 480 QuicTime::Delta offset = QuicTime::Delta::FromMicroseconds(39); |
| 481 // Now set the current time as time_wait_period + offset usecs. | 481 // Now set the current time as time_wait_period + offset usecs. |
| 482 epoll_server_.set_now_in_usec(time_wait_period.Add(offset).ToMicroseconds()); | 482 epoll_server_.set_now_in_usec((time_wait_period + offset).ToMicroseconds()); |
| 483 // After the connection_ids are cleaned up, check the next alarm interval. | 483 // After the connection_ids are cleaned up, check the next alarm interval. |
| 484 int64_t next_alarm_time = | 484 int64_t next_alarm_time = |
| 485 epoll_server_.ApproximateNowInUsec() + time_wait_period.ToMicroseconds(); | 485 epoll_server_.ApproximateNowInUsec() + time_wait_period.ToMicroseconds(); |
| 486 | 486 |
| 487 EXPECT_CALL(epoll_server_, RegisterAlarm(next_alarm_time, _)); | 487 EXPECT_CALL(epoll_server_, RegisterAlarm(next_alarm_time, _)); |
| 488 time_wait_list_manager_.CleanUpOldConnectionIds(); | 488 time_wait_list_manager_.CleanUpOldConnectionIds(); |
| 489 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_)); | 489 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_)); |
| 490 EXPECT_EQ(0u, time_wait_list_manager_.num_connections()); | 490 EXPECT_EQ(0u, time_wait_list_manager_.num_connections()); |
| 491 } | 491 } |
| 492 | 492 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), | 552 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), |
| 553 time_wait_list_manager_.num_connections()); | 553 time_wait_list_manager_.num_connections()); |
| 554 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); | 554 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); |
| 555 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); | 555 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); |
| 556 } | 556 } |
| 557 } | 557 } |
| 558 | 558 |
| 559 } // namespace | 559 } // namespace |
| 560 } // namespace test | 560 } // namespace test |
| 561 } // namespace net | 561 } // namespace net |
| OLD | NEW |