From 12bc0ce3565d3c4a1573699026418c6b71b54b3f Mon Sep 17 00:00:00 2001 From: Patrick McManus Date: Tue, 19 Jan 2016 17:48:15 -0500 Subject: [PATCH] Bug 1242597 - Fix nsSocketTransport reference loop r=dragana --- netwerk/base/nsSocketTransport2.cpp | 13 +++++++++++-- netwerk/base/nsSocketTransport2.h | 1 - 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index fdc22e09d223..423b2cb7dafe 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -473,7 +473,11 @@ nsSocketInputStream::AsyncWait(nsIInputStreamCallback *callback, bool hasError = false; { MutexAutoLock lock(mTransport->mLock); - + if (mTransport->mState != nsSocketTransport::STATE_TRANSFERRING && NS_FAILED(mCondition)) { + SOCKET_LOG(("nsSocketInputStream::AsyncWait [this=%p] " + "Not Transferring %X.\n", mTransport, mCondition)); + return NS_OK; + } if (callback && target) { // // build event proxy @@ -707,7 +711,12 @@ nsSocketOutputStream::AsyncWait(nsIOutputStreamCallback *callback, { MutexAutoLock lock(mTransport->mLock); - + if (mTransport->mState != nsSocketTransport::STATE_TRANSFERRING && NS_FAILED(mCondition)) { + // do not take the callback reference if we will not call onOutputReady + SOCKET_LOG(("nsSocketOutputStream::AsyncWait [this=%p] mTransport=%p " + "Not Transferring %X.\n",this, mTransport, mCondition)); + return NS_OK; + } if (callback && target) { // // build event proxy diff --git a/netwerk/base/nsSocketTransport2.h b/netwerk/base/nsSocketTransport2.h index 406bdce501bc..3c3c3377e876 100644 --- a/netwerk/base/nsSocketTransport2.h +++ b/netwerk/base/nsSocketTransport2.h @@ -187,7 +187,6 @@ private: enum { STATE_CLOSED, - STATE_IDLE, STATE_RESOLVING, STATE_CONNECTING, STATE_TRANSFERRING