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/quic/quic_session.h" | 5 #include "net/quic/quic_session.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 session_.OnWindowUpdateFrames(frames); | 927 session_.OnWindowUpdateFrames(frames); |
928 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked()); | 928 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked()); |
929 } | 929 } |
930 | 930 |
931 TEST_P(QuicSessionTest, TooManyUnfinishedStreamsCauseConnectionClose) { | 931 TEST_P(QuicSessionTest, TooManyUnfinishedStreamsCauseConnectionClose) { |
932 if (version() < QUIC_VERSION_18) { | 932 if (version() < QUIC_VERSION_18) { |
933 return; | 933 return; |
934 } | 934 } |
935 // If a buggy/malicious peer creates too many streams that are not ended with | 935 // If a buggy/malicious peer creates too many streams that are not ended with |
936 // a FIN or RST then we send a connection close. | 936 // a FIN or RST then we send a connection close. |
937 ValueRestore<bool> old_flag(&FLAGS_close_quic_connection_unfinished_streams, | 937 ValueRestore<bool> old_flag(&FLAGS_close_quic_connection_unfinished_streams_2, |
938 true); | 938 true); |
939 | 939 |
940 EXPECT_CALL(*connection_, | 940 EXPECT_CALL(*connection_, |
941 SendConnectionClose(QUIC_TOO_MANY_UNFINISHED_STREAMS)).Times(1); | 941 SendConnectionClose(QUIC_TOO_MANY_UNFINISHED_STREAMS)).Times(1); |
942 | 942 |
943 const int kMaxStreams = 5; | 943 const int kMaxStreams = 5; |
944 QuicSessionPeer::SetMaxOpenStreams(&session_, kMaxStreams); | 944 QuicSessionPeer::SetMaxOpenStreams(&session_, kMaxStreams); |
945 | 945 |
946 // Create kMaxStreams + 1 data streams, and close them all without receiving a | 946 // Create kMaxStreams + 1 data streams, and close them all without receiving a |
947 // FIN or a RST from the client. | 947 // FIN or a RST from the client. |
948 const int kFirstStreamId = kClientDataStreamId1; | 948 const int kFirstStreamId = kClientDataStreamId1; |
949 const int kFinalStreamId = kClientDataStreamId1 + 2 * kMaxStreams + 1; | 949 const int kFinalStreamId = kClientDataStreamId1 + 2 * kMaxStreams + 1; |
950 for (int i = kFirstStreamId; i < kFinalStreamId; i += 2) { | 950 for (int i = kFirstStreamId; i < kFinalStreamId; i += 2) { |
951 QuicStreamFrame data1(i, false, 0, MakeIOVector("HT")); | 951 QuicStreamFrame data1(i, false, 0, MakeIOVector("HT")); |
952 vector<QuicStreamFrame> frames; | 952 vector<QuicStreamFrame> frames; |
953 frames.push_back(data1); | 953 frames.push_back(data1); |
954 session_.OnStreamFrames(frames); | 954 session_.OnStreamFrames(frames); |
955 EXPECT_EQ(1u, session_.GetNumOpenStreams()); | 955 EXPECT_EQ(1u, session_.GetNumOpenStreams()); |
956 session_.CloseStream(i); | 956 session_.CloseStream(i); |
957 } | 957 } |
| 958 |
| 959 // Called after any new data is received by the session, and triggers the call |
| 960 // to close the connection. |
| 961 session_.PostProcessAfterData(); |
958 } | 962 } |
959 | 963 |
960 } // namespace | 964 } // namespace |
961 } // namespace test | 965 } // namespace test |
962 } // namespace net | 966 } // namespace net |
OLD | NEW |