| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <sys/epoll.h> | 6 #include <sys/epoll.h> |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 // Tests that the client's port can change during an established QUIC | 1467 // Tests that the client's port can change during an established QUIC |
| 1468 // connection, and that doing so does not result in the connection being | 1468 // connection, and that doing so does not result in the connection being |
| 1469 // closed by the server. | 1469 // closed by the server. |
| 1470 ASSERT_TRUE(Initialize()); | 1470 ASSERT_TRUE(Initialize()); |
| 1471 | 1471 |
| 1472 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1472 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1473 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1473 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1474 | 1474 |
| 1475 // Store the client address which was used to send the first request. | 1475 // Store the client address which was used to send the first request. |
| 1476 IPEndPoint old_address = client_->client()->GetLatestClientAddress(); | 1476 IPEndPoint old_address = client_->client()->GetLatestClientAddress(); |
| 1477 | 1477 int old_fd = client_->client()->GetLatestFD(); |
| 1478 // Stop listening and close the old FD. | |
| 1479 QuicClientPeer::CleanUpUDPSocket(client_->client(), | |
| 1480 client_->client()->GetLatestFD()); | |
| 1481 | 1478 |
| 1482 // Create a new socket before closing the old one, which will result in a new | 1479 // Create a new socket before closing the old one, which will result in a new |
| 1483 // ephemeral port. | 1480 // ephemeral port. |
| 1484 QuicClientPeer::CreateUDPSocketAndBind(client_->client()); | 1481 QuicClientPeer::CreateUDPSocketAndBind(client_->client()); |
| 1485 | 1482 |
| 1483 // Stop listening and close the old FD. |
| 1484 QuicClientPeer::CleanUpUDPSocket(client_->client(), old_fd); |
| 1485 |
| 1486 // The packet writer needs to be updated to use the new FD. | 1486 // The packet writer needs to be updated to use the new FD. |
| 1487 client_->client()->CreateQuicPacketWriter(); | 1487 client_->client()->CreateQuicPacketWriter(); |
| 1488 | 1488 |
| 1489 // Change the internal state of the client and connection to use the new port, | 1489 // Change the internal state of the client and connection to use the new port, |
| 1490 // this is done because in a real NAT rebinding the client wouldn't see any | 1490 // this is done because in a real NAT rebinding the client wouldn't see any |
| 1491 // port change, and so expects no change to incoming port. | 1491 // port change, and so expects no change to incoming port. |
| 1492 // This is kind of ugly, but needed as we are simply swapping out the client | 1492 // This is kind of ugly, but needed as we are simply swapping out the client |
| 1493 // FD rather than any more complex NAT rebinding simulation. | 1493 // FD rather than any more complex NAT rebinding simulation. |
| 1494 int new_port = client_->client()->GetLatestClientAddress().port(); | 1494 int new_port = client_->client()->GetLatestClientAddress().port(); |
| 1495 QuicClientPeer::SetClientPort(client_->client(), new_port); | 1495 QuicClientPeer::SetClientPort(client_->client(), new_port); |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2687 client_->WaitForResponse(); | 2687 client_->WaitForResponse(); |
| 2688 // TODO(fayang): Fix this test to work with stateless rejects. | 2688 // TODO(fayang): Fix this test to work with stateless rejects. |
| 2689 if (!BothSidesSupportStatelessRejects()) { | 2689 if (!BothSidesSupportStatelessRejects()) { |
| 2690 VerifyCleanConnection(false); | 2690 VerifyCleanConnection(false); |
| 2691 } | 2691 } |
| 2692 } | 2692 } |
| 2693 | 2693 |
| 2694 } // namespace | 2694 } // namespace |
| 2695 } // namespace test | 2695 } // namespace test |
| 2696 } // namespace net | 2696 } // namespace net |
| OLD | NEW |