Index: webrtc/p2p/base/turnport_unittest.cc |
diff --git a/webrtc/p2p/base/turnport_unittest.cc b/webrtc/p2p/base/turnport_unittest.cc |
index 3172ba252f2930156792fa57049d31c460f5c045..410eb9917d08cabae48d1e76e976325780a85072 100644 |
--- a/webrtc/p2p/base/turnport_unittest.cc |
+++ b/webrtc/p2p/base/turnport_unittest.cc |
@@ -490,6 +490,25 @@ TEST_F(TurnPortTest, TestTurnTcpAllocate) { |
EXPECT_NE(0, turn_port_->Candidates()[0].address().port()); |
} |
+// Test that sending a TurnAllocate will fail if the TCP connection is closed. |
+TEST_F(TurnPortTest, TestSendingAllocateWhenSocketClosed) { |
+ turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); |
+ CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); |
+ EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10 * 1024)); |
+ turn_port_->PrepareAddress(); |
+ turn_ready_ = false; |
+ turn_port_->SendAllocateRequest(0); |
+ EXPECT_TRUE_WAIT(turn_ready_, kTimeout); |
+ |
+ // Close the socket and send the request again. |
+ turn_ready_ = false; |
+ turn_port_->OnSocketClose(turn_port_->socket(), 1); |
+ turn_port_->SendAllocateRequest(0); |
+ // Wait for half a second and check. |
+ WAIT(false, kTimeout / 2); |
+ EXPECT_FALSE(turn_ready_); |
+} |
+ |
// Test case for WebRTC issue 3927 where a proxy binds to the local host address |
// instead the address that TurnPort originally bound to. The candidate pair |
// impacted by this behavior should still be used. |