| 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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 VerifyCleanConnection(false); | 755 VerifyCleanConnection(false); |
| 756 } | 756 } |
| 757 | 757 |
| 758 TEST_P(EndToEndTest, DoNotSetResumeWriteAlarmIfConnectionFlowControlBlocked) { | 758 TEST_P(EndToEndTest, DoNotSetResumeWriteAlarmIfConnectionFlowControlBlocked) { |
| 759 // Regression test for b/14677858. | 759 // Regression test for b/14677858. |
| 760 // Test that the resume write alarm is not set in QuicConnection::OnCanWrite | 760 // Test that the resume write alarm is not set in QuicConnection::OnCanWrite |
| 761 // if currently connection level flow control blocked. If set, this results in | 761 // if currently connection level flow control blocked. If set, this results in |
| 762 // an infinite loop in the EpollServer, as the alarm fires and is immediately | 762 // an infinite loop in the EpollServer, as the alarm fires and is immediately |
| 763 // rescheduled. | 763 // rescheduled. |
| 764 ASSERT_TRUE(Initialize()); | 764 ASSERT_TRUE(Initialize()); |
| 765 if (negotiated_version_ < QUIC_VERSION_19) { | |
| 766 return; | |
| 767 } | |
| 768 client_->client()->WaitForCryptoHandshakeConfirmed(); | 765 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 769 | 766 |
| 770 // Ensure both stream and connection level are flow control blocked by setting | 767 // Ensure both stream and connection level are flow control blocked by setting |
| 771 // the send window offset to 0. | 768 // the send window offset to 0. |
| 772 const uint64 kFlowControlWindow = | 769 const uint64 kFlowControlWindow = |
| 773 server_config_.GetInitialFlowControlWindowToSend(); | 770 server_config_.GetInitialFlowControlWindowToSend(); |
| 774 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); | 771 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); |
| 775 QuicSession* session = client_->client()->session(); | 772 QuicSession* session = client_->client()->session(); |
| 776 QuicFlowControllerPeer::SetSendWindowOffset(stream->flow_controller(), 0); | 773 QuicFlowControllerPeer::SetSendWindowOffset(stream->flow_controller(), 0); |
| 777 QuicFlowControllerPeer::SetSendWindowOffset(session->flow_controller(), 0); | 774 QuicFlowControllerPeer::SetSendWindowOffset(session->flow_controller(), 0); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 QuicTime::Delta::FromMicroseconds(500)); | 847 QuicTime::Delta::FromMicroseconds(500)); |
| 851 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: | 848 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: |
| 852 // that's enough to validate timeout in this case. | 849 // that's enough to validate timeout in this case. |
| 853 Initialize(); | 850 Initialize(); |
| 854 while (client_->client()->connected()) { | 851 while (client_->client()->connected()) { |
| 855 client_->client()->WaitForEvents(); | 852 client_->client()->WaitForEvents(); |
| 856 } | 853 } |
| 857 } | 854 } |
| 858 | 855 |
| 859 TEST_P(EndToEndTest, NegotiateMaxOpenStreams) { | 856 TEST_P(EndToEndTest, NegotiateMaxOpenStreams) { |
| 857 ValueRestore<bool> old_flag(&FLAGS_quic_allow_more_open_streams, true); |
| 858 |
| 860 // Negotiate 1 max open stream. | 859 // Negotiate 1 max open stream. |
| 861 client_config_.SetMaxStreamsPerConnection(1, 1); | 860 client_config_.SetMaxStreamsPerConnection(1, 1); |
| 862 ASSERT_TRUE(Initialize()); | 861 ASSERT_TRUE(Initialize()); |
| 863 client_->client()->WaitForCryptoHandshakeConfirmed(); | 862 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 864 | 863 |
| 865 // Make the client misbehave after negotiation. | 864 // Make the client misbehave after negotiation. |
| 866 QuicSessionPeer::SetMaxOpenStreams(client_->client()->session(), 10); | 865 const int kServerMaxStreams = kMaxStreamsMinimumIncrement + 1; |
| 866 QuicSessionPeer::SetMaxOpenStreams(client_->client()->session(), |
| 867 kServerMaxStreams + 1); |
| 867 | 868 |
| 868 HTTPMessage request(HttpConstants::HTTP_1_1, | 869 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo"); |
| 869 HttpConstants::POST, "/foo"); | |
| 870 request.AddHeader("content-length", "3"); | 870 request.AddHeader("content-length", "3"); |
| 871 request.set_has_complete_message(false); | 871 request.set_has_complete_message(false); |
| 872 | 872 |
| 873 // Open two simultaneous streams. | 873 // The server supports a small number of additional streams beyond the |
| 874 client_->SendMessage(request); | 874 // negotiated limit. Open enough streams to go beyond that limit. |
| 875 client_->SendMessage(request); | 875 for (int i = 0; i < kServerMaxStreams + 1; ++i) { |
| 876 client_->SendMessage(request); |
| 877 } |
| 876 client_->WaitForResponse(); | 878 client_->WaitForResponse(); |
| 877 | 879 |
| 878 EXPECT_FALSE(client_->connected()); | 880 EXPECT_FALSE(client_->connected()); |
| 879 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 881 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
| 880 EXPECT_EQ(QUIC_TOO_MANY_OPEN_STREAMS, client_->connection_error()); | 882 EXPECT_EQ(QUIC_TOO_MANY_OPEN_STREAMS, client_->connection_error()); |
| 881 } | 883 } |
| 882 | 884 |
| 883 TEST_P(EndToEndTest, NegotiateCongestionControl) { | 885 TEST_P(EndToEndTest, NegotiateCongestionControl) { |
| 884 ASSERT_TRUE(Initialize()); | 886 ASSERT_TRUE(Initialize()); |
| 885 client_->client()->WaitForCryptoHandshakeConfirmed(); | 887 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 const uint32 kClientSessionIFCW = 234567; | 1240 const uint32 kClientSessionIFCW = 234567; |
| 1239 set_client_initial_stream_flow_control_receive_window(kClientStreamIFCW); | 1241 set_client_initial_stream_flow_control_receive_window(kClientStreamIFCW); |
| 1240 set_client_initial_session_flow_control_receive_window(kClientSessionIFCW); | 1242 set_client_initial_session_flow_control_receive_window(kClientSessionIFCW); |
| 1241 | 1243 |
| 1242 const uint32 kServerStreamIFCW = 654321; | 1244 const uint32 kServerStreamIFCW = 654321; |
| 1243 const uint32 kServerSessionIFCW = 765432; | 1245 const uint32 kServerSessionIFCW = 765432; |
| 1244 set_server_initial_stream_flow_control_receive_window(kServerStreamIFCW); | 1246 set_server_initial_stream_flow_control_receive_window(kServerStreamIFCW); |
| 1245 set_server_initial_session_flow_control_receive_window(kServerSessionIFCW); | 1247 set_server_initial_session_flow_control_receive_window(kServerSessionIFCW); |
| 1246 | 1248 |
| 1247 ASSERT_TRUE(Initialize()); | 1249 ASSERT_TRUE(Initialize()); |
| 1248 if (negotiated_version_ <= QUIC_VERSION_19) { | 1250 if (negotiated_version_ == QUIC_VERSION_19) { |
| 1249 return; | 1251 return; |
| 1250 } | 1252 } |
| 1251 | 1253 |
| 1252 // Values are exchanged during crypto handshake, so wait for that to finish. | 1254 // Values are exchanged during crypto handshake, so wait for that to finish. |
| 1253 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1255 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 1254 server_thread_->WaitForCryptoHandshakeConfirmed(); | 1256 server_thread_->WaitForCryptoHandshakeConfirmed(); |
| 1255 | 1257 |
| 1256 // Open a data stream to make sure the stream level flow control is updated. | 1258 // Open a data stream to make sure the stream level flow control is updated. |
| 1257 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); | 1259 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); |
| 1258 stream->SendBody("hello", false); | 1260 stream->SendBody("hello", false); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 QuicSession* session = dispatcher->session_map().begin()->second; | 1362 QuicSession* session = dispatcher->session_map().begin()->second; |
| 1361 EXPECT_EQ(0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset( | 1363 EXPECT_EQ(0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset( |
| 1362 session).size()); | 1364 session).size()); |
| 1363 server_thread_->Resume(); | 1365 server_thread_->Resume(); |
| 1364 } | 1366 } |
| 1365 | 1367 |
| 1366 } // namespace | 1368 } // namespace |
| 1367 } // namespace test | 1369 } // namespace test |
| 1368 } // namespace tools | 1370 } // namespace tools |
| 1369 } // namespace net | 1371 } // namespace net |
| OLD | NEW |