summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 09:03:12 +0000
committerukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 09:03:12 +0000
commit425bff92e9d536eef7c079c559df480a1eb48c34 (patch)
tree88296d37fa47496e425e0357c8d7b8cf2a98eb2b /net
parente7d19ebde89ca50807999eba062cfb2b47ac9337 (diff)
downloadchromium_src-425bff92e9d536eef7c079c559df480a1eb48c34.zip
chromium_src-425bff92e9d536eef7c079c559df480a1eb48c34.tar.gz
chromium_src-425bff92e9d536eef7c079c559df480a1eb48c34.tar.bz2
Fix leak in WebSocketThrottleTest::Throttle
chromium r43192 add check of next_state_ to call DoLoop in SocketStream::Close(), so if next_state_ is STATE_NONE, we don't need socket->AddRef() to balance Release() in SocketStream::Finish(). BUG=39979 TEST=valgrind passes WebSocketThrottleTest Review URL: http://codereview.chromium.org/1517010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/websockets/websocket_throttle_unittest.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/net/websockets/websocket_throttle_unittest.cc b/net/websockets/websocket_throttle_unittest.cc
index 61e5e4b..91d588f 100644
--- a/net/websockets/websocket_throttle_unittest.cc
+++ b/net/websockets/websocket_throttle_unittest.cc
@@ -64,10 +64,15 @@ class WebSocketThrottleTest : public PlatformTest {
static void MockSocketStreamConnect(
SocketStream* socket, struct addrinfo* head) {
socket->CopyAddrInfo(head);
- // Add reference to socket as done in SocketStream::Connect().
- // Balanced with Release() in SocketStream::Finish() which will be
- // called by SocketStream::DetachDelegate().
- socket->AddRef();
+ // In SocketStream::Connect(), it adds reference to socket, which is
+ // balanced with SocketStream::Finish() that is finally called from
+ // SocketStream::Close() or SocketStream::DetachDelegate(), when
+ // next_state_ is not STATE_NONE.
+ // If next_state_ is STATE_NONE, SocketStream::Close() or
+ // SocketStream::DetachDelegate() won't call SocketStream::Finish(),
+ // so Release() won't be called. Thus, we don't need socket->AddRef()
+ // here.
+ DCHECK_EQ(socket->next_state_, SocketStream::STATE_NONE);
}
};
@@ -271,6 +276,7 @@ TEST_F(WebSocketThrottleTest, Throttle) {
w4->OnClose(s4.get());
s4->DetachDelegate();
DLOG(INFO) << "Done";
+ MessageLoopForIO::current()->RunAllPending();
}
}