diff --git a/security/manager/ssl/src/nsSSLThread.cpp b/security/manager/ssl/src/nsSSLThread.cpp index c6ba6077c10..fd60e18e1cf 100644 --- a/security/manager/ssl/src/nsSSLThread.cpp +++ b/security/manager/ssl/src/nsSSLThread.cpp @@ -48,8 +48,7 @@ extern PRLogModuleInfo* gPIPNSSLog; nsSSLThread::nsSSLThread() : mBusySocket(nsnull), - mSocketScheduledToBeDestroyed(nsnull), - mPendingHTTPRequest(nsnull) + mSocketScheduledToBeDestroyed(nsnull) { NS_ASSERTION(!ssl_thread_singleton, "nsSSLThread is a singleton, caller attempts to create another instance!"); @@ -379,7 +378,7 @@ PRStatus nsSSLThread::requestClose(nsNSSSocketInfo *si) return PR_FAILURE; PRBool close_later = PR_FALSE; - nsIRequest* requestToCancel = nsnull; + nsCOMPtr requestToCancel; { nsAutoLock threadLock(ssl_thread_singleton->mMutex); @@ -395,8 +394,7 @@ PRStatus nsSSLThread::requestClose(nsNSSSocketInfo *si) if (ssl_thread_singleton->mPendingHTTPRequest) { - requestToCancel = ssl_thread_singleton->mPendingHTTPRequest; - ssl_thread_singleton->mPendingHTTPRequest = nsnull; + requestToCancel.swap(ssl_thread_singleton->mPendingHTTPRequest); } close_later = PR_TRUE; @@ -417,7 +415,7 @@ PRStatus nsSSLThread::requestClose(nsNSSSocketInfo *si) NS_WARNING("Attempt to close SSL socket from a thread that is not the main thread. Can not cancel pending HTTP request from NSS"); } - NS_RELEASE(requestToCancel); + requestToCancel = nsnull; } if (!close_later) @@ -1129,7 +1127,6 @@ void nsSSLThread::rememberPendingHTTPRequest(nsIRequest *aRequest) nsAutoLock threadLock(ssl_thread_singleton->mMutex); - NS_IF_ADDREF(aRequest); ssl_thread_singleton->mPendingHTTPRequest = aRequest; } @@ -1143,9 +1140,6 @@ void nsSSLThread::cancelPendingHTTPRequest() if (ssl_thread_singleton->mPendingHTTPRequest) { ssl_thread_singleton->mPendingHTTPRequest->Cancel(NS_ERROR_ABORT); - - NS_RELEASE(ssl_thread_singleton->mPendingHTTPRequest); - ssl_thread_singleton->mPendingHTTPRequest = nsnull; } } diff --git a/security/manager/ssl/src/nsSSLThread.h b/security/manager/ssl/src/nsSSLThread.h index e72062fcafc..5e60f11a52a 100644 --- a/security/manager/ssl/src/nsSSLThread.h +++ b/security/manager/ssl/src/nsSSLThread.h @@ -79,7 +79,7 @@ private: // As this HTTP request depends on some original SSL socket, // we can use this handle to cancel the dependent HTTP request, // should we be asked to close the original SSL socket. - nsIRequest* mPendingHTTPRequest; + nsCOMPtr mPendingHTTPRequest; virtual void Run(void);