diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-17 22:21:10 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-17 22:21:10 +0000 |
commit | 46f6f38fefe5bfca416518b99179cc3bc2ed68ac (patch) | |
tree | fdb26e041757662e2825b43317b943f8ae2963d7 /net | |
parent | 09a99a0d385573b0119c74a15190813f09853619 (diff) | |
download | chromium_src-46f6f38fefe5bfca416518b99179cc3bc2ed68ac.zip chromium_src-46f6f38fefe5bfca416518b99179cc3bc2ed68ac.tar.gz chromium_src-46f6f38fefe5bfca416518b99179cc3bc2ed68ac.tar.bz2 |
Fix a memory leak in client_socket_pool_unittest.cc.
Need to run the MessageLoop one time to run a task to delete the canceled ConnectingSocket.
Also reorder the test to help hide the minor race condition here.
Review URL: http://codereview.chromium.org/115455
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16266 0039d316-1c4b-4281-b951-d872f2087c98
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 |