Bug 936685 - Clear more listeners in nsHttpConnectionMgr::nsHalfOpenSocket::Abandon. r=mcmanus
authorSteve Workman <sworkman@mozilla.com>
Sat, 09 Nov 2013 10:40:52 -0800
changeset 166601 4494b9b0a0e94e346f8455838ca6f25091ca4100
parent 166600 1e7e095cfcf4e21ac5bfdf2788d4fa48c97185d9
child 166602 fd450b08821876736fe86b35d13ecac6f1bb2465
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs936685
milestone27.0a2
Bug 936685 - Clear more listeners in nsHttpConnectionMgr::nsHalfOpenSocket::Abandon. r=mcmanus
netwerk/protocol/http/nsHttpConnectionMgr.cpp
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -2833,29 +2833,47 @@ nsHttpConnectionMgr::nsHalfOpenSocket::A
 {
     LOG(("nsHalfOpenSocket::Abandon [this=%p ent=%s]",
          this, mEnt->mConnInfo->Host()));
 
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
     nsRefPtr<nsHalfOpenSocket> deleteProtector(this);
 
+    // Tell socket (and backup socket) to forget the half open socket.
+    if (mSocketTransport) {
+        mSocketTransport->SetEventSink(nullptr, nullptr);
+        mSocketTransport->SetSecurityCallbacks(nullptr);
+        mSocketTransport = nullptr;
+    }
+    if (mBackupTransport) {
+        mBackupTransport->SetEventSink(nullptr, nullptr);
+        mBackupTransport->SetSecurityCallbacks(nullptr);
+        mBackupTransport = nullptr;
+    }
+
+    // Tell output stream (and backup) to forget the half open socket.
     if (mStreamOut) {
         gHttpHandler->ConnMgr()->RecvdConnect();
         mStreamOut->AsyncWait(nullptr, 0, 0, nullptr);
         mStreamOut = nullptr;
     }
     if (mBackupStreamOut) {
         gHttpHandler->ConnMgr()->RecvdConnect();
         mBackupStreamOut->AsyncWait(nullptr, 0, 0, nullptr);
         mBackupStreamOut = nullptr;
     }
 
+    // Lose references to input stream (and backup).
+    mStreamIn = mBackupStreamIn = nullptr;
+
+    // Stop the timer - we don't want any new backups.
     CancelBackupTimer();
 
+    // Remove the half open from the connection entry.
     if (mEnt)
         mEnt->RemoveHalfOpen(this);
     mEnt = nullptr;
 }
 
 double
 nsHttpConnectionMgr::nsHalfOpenSocket::Duration(TimeStamp epoch)
 {