OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 ASSERT_EQ_WAIT(1, ch2.complete_count(), kTimeout); | 2417 ASSERT_EQ_WAIT(1, ch2.complete_count(), kTimeout); |
2418 | 2418 |
2419 // Send a ping from src to dst. | 2419 // Send a ping from src to dst. |
2420 ch1.CreateConnection(GetCandidate(port2)); | 2420 ch1.CreateConnection(GetCandidate(port2)); |
2421 ASSERT_TRUE(ch1.conn() != NULL); | 2421 ASSERT_TRUE(ch1.conn() != NULL); |
2422 EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); | 2422 EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); |
2423 EXPECT_TRUE_WAIT(ch1.conn()->connected(), kTimeout); // for TCP connect | 2423 EXPECT_TRUE_WAIT(ch1.conn()->connected(), kTimeout); // for TCP connect |
2424 ch1.Ping(); | 2424 ch1.Ping(); |
2425 WAIT(!ch2.remote_address().IsNil(), kTimeout); | 2425 WAIT(!ch2.remote_address().IsNil(), kTimeout); |
2426 | 2426 |
2427 // Data should be unsendable until the connection is accepted. | 2427 // Data should be sendable before the connection is accepted. |
2428 char data[] = "abcd"; | 2428 char data[] = "abcd"; |
2429 int data_size = arraysize(data); | 2429 int data_size = arraysize(data); |
2430 rtc::PacketOptions options; | 2430 rtc::PacketOptions options; |
2431 EXPECT_EQ(SOCKET_ERROR, ch1.conn()->Send(data, data_size, options)); | 2431 EXPECT_EQ(data_size, ch1.conn()->Send(data, data_size, options)); |
2432 | 2432 |
2433 // Accept the connection to return the binding response, transition to | 2433 // Accept the connection to return the binding response, transition to |
2434 // writable, and allow data to be sent. | 2434 // writable, and allow data to be sent. |
2435 ch2.AcceptConnection(GetCandidate(port1)); | 2435 ch2.AcceptConnection(GetCandidate(port1)); |
2436 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(), | 2436 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(), |
2437 kTimeout); | 2437 kTimeout); |
2438 EXPECT_EQ(data_size, ch1.conn()->Send(data, data_size, options)); | 2438 EXPECT_EQ(data_size, ch1.conn()->Send(data, data_size, options)); |
2439 | 2439 |
2440 // Ask the connection to update state as if enough time has passed to lose | 2440 // Ask the connection to update state as if enough time has passed to lose |
2441 // full writability and 5 pings went unresponded to. We'll accomplish the | 2441 // full writability and 5 pings went unresponded to. We'll accomplish the |
(...skipping 15 matching lines...) Expand all Loading... |
2457 | 2457 |
2458 // Wait long enough for a full timeout (past however long we've already | 2458 // Wait long enough for a full timeout (past however long we've already |
2459 // waited). | 2459 // waited). |
2460 for (uint32_t i = 1; i <= CONNECTION_WRITE_CONNECT_FAILURES; ++i) { | 2460 for (uint32_t i = 1; i <= CONNECTION_WRITE_CONNECT_FAILURES; ++i) { |
2461 ch1.Ping(unreliable_timeout_delay + i); | 2461 ch1.Ping(unreliable_timeout_delay + i); |
2462 } | 2462 } |
2463 ch1.conn()->UpdateState(unreliable_timeout_delay + CONNECTION_WRITE_TIMEOUT + | 2463 ch1.conn()->UpdateState(unreliable_timeout_delay + CONNECTION_WRITE_TIMEOUT + |
2464 500u); | 2464 500u); |
2465 EXPECT_EQ(Connection::STATE_WRITE_TIMEOUT, ch1.conn()->write_state()); | 2465 EXPECT_EQ(Connection::STATE_WRITE_TIMEOUT, ch1.conn()->write_state()); |
2466 | 2466 |
2467 // Now that the connection has completely timed out, data send should fail. | 2467 // Even if the connection has timed out, the Connection shouldn't block |
2468 EXPECT_EQ(SOCKET_ERROR, ch1.conn()->Send(data, data_size, options)); | 2468 // the sending of data. |
| 2469 EXPECT_EQ(data_size, ch1.conn()->Send(data, data_size, options)); |
2469 | 2470 |
2470 ch1.Stop(); | 2471 ch1.Stop(); |
2471 ch2.Stop(); | 2472 ch2.Stop(); |
2472 } | 2473 } |
2473 | 2474 |
2474 TEST_F(PortTest, TestTimeoutForNeverWritable) { | 2475 TEST_F(PortTest, TestTimeoutForNeverWritable) { |
2475 UDPPort* port1 = CreateUdpPort(kLocalAddr1); | 2476 UDPPort* port1 = CreateUdpPort(kLocalAddr1); |
2476 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); | 2477 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); |
2477 UDPPort* port2 = CreateUdpPort(kLocalAddr2); | 2478 UDPPort* port2 = CreateUdpPort(kLocalAddr2); |
2478 port2->SetIceRole(cricket::ICEROLE_CONTROLLED); | 2479 port2->SetIceRole(cricket::ICEROLE_CONTROLLED); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2711 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); | 2712 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); |
2712 EXPECT_NE(conn1, conn2); | 2713 EXPECT_NE(conn1, conn2); |
2713 conn_in_use = port->GetConnection(address); | 2714 conn_in_use = port->GetConnection(address); |
2714 EXPECT_EQ(conn2, conn_in_use); | 2715 EXPECT_EQ(conn2, conn_in_use); |
2715 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); | 2716 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); |
2716 | 2717 |
2717 // Make sure the new connection was not deleted. | 2718 // Make sure the new connection was not deleted. |
2718 rtc::Thread::Current()->ProcessMessages(300); | 2719 rtc::Thread::Current()->ProcessMessages(300); |
2719 EXPECT_TRUE(port->GetConnection(address) != nullptr); | 2720 EXPECT_TRUE(port->GetConnection(address) != nullptr); |
2720 } | 2721 } |
OLD | NEW |