Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: net/socket/websocket_transport_client_socket_pool_unittest.cc

Issue 394113003: Fix WebSocket race between close and connect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase harder. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/websocket_transport_client_socket_pool.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/websocket_transport_client_socket_pool_unittest.cc
diff --git a/net/socket/websocket_transport_client_socket_pool_unittest.cc b/net/socket/websocket_transport_client_socket_pool_unittest.cc
index e61c9f44efda4292dbc9fd57094fc5e350d8bd30..76e898d3ed0762a8cdbd39a9ec446858d23af728 100644
--- a/net/socket/websocket_transport_client_socket_pool_unittest.cc
+++ b/net/socket/websocket_transport_client_socket_pool_unittest.cc
@@ -1085,6 +1085,31 @@ TEST_F(WebSocketTransportClientSocketPoolTest,
request(0)->handle()->Reset();
}
+// Sockets should not be leaked if CancelRequest() is called in between
+// SetSocket() being called on the ClientSocketHandle and InvokeUserCallback().
+TEST_F(WebSocketTransportClientSocketPoolTest, CancelRequestReclaimsSockets) {
+ host_resolver_->set_synchronous_mode(true);
+ MockTransportClientSocketFactory::ClientSocketType socket_types[] = {
+ MockTransportClientSocketFactory::MOCK_TRIGGERABLE_CLIENT_SOCKET,
+ MockTransportClientSocketFactory::MOCK_CLIENT_SOCKET};
+
+ client_socket_factory_.set_client_socket_types(socket_types,
+ arraysize(socket_types));
+
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority));
+
+ base::Closure connect_trigger =
+ client_socket_factory_.WaitForTriggerableSocketCreation();
+
+ connect_trigger.Run(); // Calls InvokeUserCallbackLater()
+
+ request(0)->handle()->Reset(); // calls CancelRequest()
+
+ // We should now be able to create a new connection without blocking on the
+ // endpoint lock.
+ EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/socket/websocket_transport_client_socket_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698