summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 09:09:53 +0000
committerukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 09:09:53 +0000
commitd936daa4b3f65d9e54497112946a50b56f166747 (patch)
tree0c1dc4ac3c30718cfe851bbe96edfec590ef7320 /net
parentebfa161e59a2c2481c4830aa54a693bcb8db04d6 (diff)
downloadchromium_src-d936daa4b3f65d9e54497112946a50b56f166747.zip
chromium_src-d936daa4b3f65d9e54497112946a50b56f166747.tar.gz
chromium_src-d936daa4b3f65d9e54497112946a50b56f166747.tar.bz2
Fix race condition in SocketStream::Close().
it must not run DoLoop if next_state_ is already STATE_NONE. If next_state_ is already STATE_NONE, it means Finish() was already called, so it had called Release() for AddRef() in Connect(). BUG=none TEST=none Review URL: http://codereview.chromium.org/1579003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/socket_stream/socket_stream.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc
index 1d10ad5..bdd2894 100644
--- a/net/socket_stream/socket_stream.cc
+++ b/net/socket_stream/socket_stream.cc
@@ -167,6 +167,12 @@ void SocketStream::Close() {
"The current MessageLoop must exist";
DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) <<
"The current MessageLoop must be TYPE_IO";
+ // If next_state_ is STATE_NONE, the socket was not opened, or already
+ // closed. So, return immediately.
+ // Otherwise, it might call Finish() more than once, so breaks balance
+ // of AddRef() and Release() in Connect() and Finish(), respectively.
+ if (next_state_ == STATE_NONE)
+ return;
if (socket_.get() && socket_->IsConnected())
socket_->Disconnect();
next_state_ = STATE_CLOSE;