Bug 1556491 - Always close http transactions from nsHttpConnection::CloseTransaction even when the connection or its filter does not refer any, r=dragana
authorHonza Bambas <honzab.moz@firemni.cz>
Sat, 06 Jul 2019 20:17:59 +0000
changeset 541225 1a5bc9c6cfcd134a813cbf269b0b11a02ddd22a7
parent 541224 d6cfc645e0c0a4da20eb79e7b9c2653ef323b94e
child 541226 a75bba7b4bbb202429335a15a33a5c5eb77b42e2
push id11533
push userarchaeopteryx@coole-files.de
push dateMon, 08 Jul 2019 18:18:03 +0000
treeherdermozilla-beta@f4452e031aed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1556491
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1556491 - Always close http transactions from nsHttpConnection::CloseTransaction even when the connection or its filter does not refer any, r=dragana Differential Revision: https://phabricator.services.mozilla.com/D37102
netwerk/protocol/http/nsHttpConnection.cpp
--- a/netwerk/protocol/http/nsHttpConnection.cpp
+++ b/netwerk/protocol/http/nsHttpConnection.cpp
@@ -1790,16 +1790,17 @@ HttpVersion nsHttpConnection::Version() 
 
 void nsHttpConnection::CloseTransaction(nsAHttpTransaction* trans,
                                         nsresult reason, bool aIsShutdown) {
   LOG(("nsHttpConnection::CloseTransaction[this=%p trans=%p reason=%" PRIx32
        "]\n",
        this, trans, static_cast<uint32_t>(reason)));
 
   MOZ_ASSERT((trans == mTransaction) ||
+             (mTLSFilter && !mTLSFilter->Transaction()) ||
              (mTLSFilter && mTLSFilter->Transaction() == trans));
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
 
   if (mCurrentBytesRead > mMaxBytesRead) mMaxBytesRead = mCurrentBytesRead;
 
   // mask this error code because its not a real error.
   if (reason == NS_BASE_STREAM_CLOSED) reason = NS_OK;
 
@@ -1813,20 +1814,33 @@ void nsHttpConnection::CloseTransaction(
 
   if (!mTransaction && mTLSFilter) {
     // In case of a race when the transaction is being closed before the tunnel
     // is established we need to carry closing status on the proxied
     // transaction.
     // Not doing this leads to use of this closed connection to activate the
     // not closed transaction what will likely lead to a use of a closed ssl
     // socket and may cause a crash because of an unexpected use.
-    mTLSFilter->Close(reason);
+    //
+    // There can possibly be two states: the actual transaction is still hanging
+    // of off the filter, or has not even been assigned on it yet.  In the
+    // latter case we simply must close the transaction given to us via the
+    // argument.
+    if (!mTLSFilter->Transaction()) {
+      LOG(("  closing transaction directly"));
+      MOZ_ASSERT(trans);
+      trans->Close(reason);
+    } else {
+      LOG(("  closing transactin hanging of off mTLSFilter"));
+      mTLSFilter->Close(reason);
+    }
   }
 
   if (mTransaction) {
+    LOG(("  closing associated mTransaction"));
     mHttp1xTransactionCount += mTransaction->Http1xTransactionCount();
 
     mTransaction->Close(reason);
     mTransaction = nullptr;
   }
 
   {
     MutexAutoLock lock(mCallbacksLock);