diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/base/client_socket_pool_unittest.cc | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/net/base/client_socket_pool_unittest.cc b/net/base/client_socket_pool_unittest.cc index 8b59914..73fc0e3 100644 --- a/net/base/client_socket_pool_unittest.cc +++ b/net/base/client_socket_pool_unittest.cc @@ -310,6 +310,20 @@ TEST_F(ClientSocketPoolTest, PendingRequests_NoKeepAlive) { EXPECT_EQ(kNumRequests, TestSocketRequest::completion_count); } +// This test will start up a RequestSocket() and then immediately Cancel() it. +// The pending host resolution will eventually complete, and destroy the +// ClientSocketPool which will crash if the group was not cleared properly. +TEST_F(ClientSocketPoolTest, CancelRequestClearGroup) { + TestSocketRequest req(pool_.get(), &request_order_); + EXPECT_EQ(ERR_IO_PENDING, + req.handle.Init("a", "www.google.com", 80, 5, &req)); + req.handle.Reset(); + // There is a race condition here. If the worker pool doesn't post the task + // before we get here, then this might not run ConnectingSocket::IOComplete + // and therefore leak the canceled ConnectingSocket. + MessageLoop::current()->RunAllPending(); +} + TEST_F(ClientSocketPoolTest, CancelRequest) { scoped_ptr<TestSocketRequest> reqs[kNumRequests]; @@ -371,16 +385,6 @@ TEST_F(ClientSocketPoolTest, CancelRequest) { "earlier into the queue."; } -// This test will start up a RequestSocket() and then immediately Cancel() it. -// The pending host resolution will eventually complete, and destroy the -// ClientSocketPool which will crash if the group was not cleared properly. -TEST_F(ClientSocketPoolTest, CancelRequestClearGroup) { - TestSocketRequest req(pool_.get(), &request_order_); - EXPECT_EQ(ERR_IO_PENDING, - req.handle.Init("a", "www.google.com", 80, 5, &req)); - req.handle.Reset(); -} - } // namespace } // namespace net |