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 <string> | 6 #include <string> |
7 #include <sys/epoll.h> | 7 #include <sys/epoll.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 993 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
994 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 994 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
995 | 995 |
996 // Store the client address which was used to send the first request. | 996 // Store the client address which was used to send the first request. |
997 IPEndPoint old_address = client_->client()->client_address(); | 997 IPEndPoint old_address = client_->client()->client_address(); |
998 | 998 |
999 // Stop listening on the old FD. | 999 // Stop listening on the old FD. |
1000 EpollServer* eps = client_->client()->epoll_server(); | 1000 EpollServer* eps = client_->client()->epoll_server(); |
1001 int old_fd = client_->client()->fd(); | 1001 int old_fd = client_->client()->fd(); |
1002 eps->UnregisterFD(old_fd); | 1002 eps->UnregisterFD(old_fd); |
| 1003 // Create a new socket before closing the old one, which will result in a new |
| 1004 // ephemeral port. |
| 1005 QuicClientPeer::CreateUDPSocket(client_->client()); |
1003 close(old_fd); | 1006 close(old_fd); |
1004 | 1007 |
1005 // Create a new socket, which will result in a new ephemeral port. | |
1006 QuicClientPeer::CreateUDPSocket(client_->client()); | |
1007 | |
1008 // The packet writer needs to be updated to use the new FD. | 1008 // The packet writer needs to be updated to use the new FD. |
1009 client_->client()->CreateQuicPacketWriter(); | 1009 client_->client()->CreateQuicPacketWriter(); |
1010 | 1010 |
1011 // Change the internal state of the client and connection to use the new port, | 1011 // Change the internal state of the client and connection to use the new port, |
1012 // this is done because in a real NAT rebinding the client wouldn't see any | 1012 // this is done because in a real NAT rebinding the client wouldn't see any |
1013 // port change, and so expects no change to incoming port. | 1013 // port change, and so expects no change to incoming port. |
1014 // This is kind of ugly, but needed as we are simply swapping out the client | 1014 // This is kind of ugly, but needed as we are simply swapping out the client |
1015 // FD rather than any more complex NAT rebinding simulation. | 1015 // FD rather than any more complex NAT rebinding simulation. |
1016 int new_port = client_->client()->client_address().port(); | 1016 int new_port = client_->client()->client_address().port(); |
1017 QuicClientPeer::SetClientPort(client_->client(), new_port); | 1017 QuicClientPeer::SetClientPort(client_->client(), new_port); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 QuicSession* session = dispatcher->session_map().begin()->second; | 1065 QuicSession* session = dispatcher->session_map().begin()->second; |
1066 EXPECT_EQ(kClientIFCW, | 1066 EXPECT_EQ(kClientIFCW, |
1067 session->config()->ReceivedInitialFlowControlWindowBytes()); | 1067 session->config()->ReceivedInitialFlowControlWindowBytes()); |
1068 server_thread_->Resume(); | 1068 server_thread_->Resume(); |
1069 } | 1069 } |
1070 | 1070 |
1071 } // namespace | 1071 } // namespace |
1072 } // namespace test | 1072 } // namespace test |
1073 } // namespace tools | 1073 } // namespace tools |
1074 } // namespace net | 1074 } // namespace net |
OLD | NEW |