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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 header.public_header.reset_flag = true; | 1410 header.public_header.reset_flag = true; |
1411 header.public_header.version_flag = false; | 1411 header.public_header.version_flag = false; |
1412 header.rejected_sequence_number = 10101; | 1412 header.rejected_sequence_number = 10101; |
1413 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), | 1413 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), |
1414 Perspective::IS_SERVER); | 1414 Perspective::IS_SERVER); |
1415 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); | 1415 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); |
1416 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; | 1416 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; |
1417 client_->client()->session()->connection()->set_debug_visitor(&visitor); | 1417 client_->client()->session()->connection()->set_debug_visitor(&visitor); |
1418 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) | 1418 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) |
1419 .Times(1); | 1419 .Times(1); |
| 1420 // We must pause the server's thread in order to call WritePacket without |
| 1421 // race conditions. |
| 1422 server_thread_->Pause(); |
1420 server_writer_->WritePacket(packet->data(), packet->length(), | 1423 server_writer_->WritePacket(packet->data(), packet->length(), |
1421 server_address_.address(), | 1424 server_address_.address(), |
1422 client_->client()->client_address()); | 1425 client_->client()->client_address()); |
| 1426 server_thread_->Resume(); |
1423 | 1427 |
1424 // The connection should be unaffected. | 1428 // The connection should be unaffected. |
1425 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1429 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
1426 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1430 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
1427 | 1431 |
1428 client_->client()->session()->connection()->set_debug_visitor(nullptr); | 1432 client_->client()->session()->connection()->set_debug_visitor(nullptr); |
1429 } | 1433 } |
1430 | 1434 |
1431 // Send a public reset from the client for a different connection ID. | 1435 // Send a public reset from the client for a different connection ID. |
1432 // It should be ignored. | 1436 // It should be ignored. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 header.reset_flag = true; | 1470 header.reset_flag = true; |
1467 header.version_flag = true; | 1471 header.version_flag = true; |
1468 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), | 1472 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), |
1469 Perspective::IS_SERVER); | 1473 Perspective::IS_SERVER); |
1470 scoped_ptr<QuicEncryptedPacket> packet( | 1474 scoped_ptr<QuicEncryptedPacket> packet( |
1471 framer.BuildVersionNegotiationPacket(header, server_supported_versions_)); | 1475 framer.BuildVersionNegotiationPacket(header, server_supported_versions_)); |
1472 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; | 1476 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; |
1473 client_->client()->session()->connection()->set_debug_visitor(&visitor); | 1477 client_->client()->session()->connection()->set_debug_visitor(&visitor); |
1474 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) | 1478 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) |
1475 .Times(1); | 1479 .Times(1); |
| 1480 // We must pause the server's thread in order to call WritePacket without |
| 1481 // race conditions. |
| 1482 server_thread_->Pause(); |
1476 server_writer_->WritePacket(packet->data(), packet->length(), | 1483 server_writer_->WritePacket(packet->data(), packet->length(), |
1477 server_address_.address(), | 1484 server_address_.address(), |
1478 client_->client()->client_address()); | 1485 client_->client()->client_address()); |
| 1486 server_thread_->Resume(); |
1479 | 1487 |
1480 // The connection should be unaffected. | 1488 // The connection should be unaffected. |
1481 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1489 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
1482 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1490 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
1483 | 1491 |
1484 client_->client()->session()->connection()->set_debug_visitor(nullptr); | 1492 client_->client()->session()->connection()->set_debug_visitor(nullptr); |
1485 } | 1493 } |
1486 | 1494 |
1487 } // namespace | 1495 } // namespace |
1488 } // namespace test | 1496 } // namespace test |
1489 } // namespace tools | 1497 } // namespace tools |
1490 } // namespace net | 1498 } // namespace net |
OLD | NEW |