[tbb-commits] [tor-browser] 263/311: Bug 1755767 - Make sure not to call HandshakeDone after Close() is calleed r=necko-reviewers, kershaw a=dmeehan

gitolite role git at cupani.torproject.org
Tue Apr 26 15:31:03 UTC 2022


This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch geckoview-99.0.1-11.0-1
in repository tor-browser.

commit b98f0adbce7b259b1d929b8b9461c2830297daf9
Author: Dragana Damjanovic <dd.mozilla at gmail.com>
AuthorDate: Thu Mar 24 12:35:37 2022 +0000

    Bug 1755767 - Make sure not to call HandshakeDone after Close() is calleed r=necko-reviewers,kershaw a=dmeehan
    
    Differential Revision: https://phabricator.services.mozilla.com/D141957
---
 netwerk/protocol/http/nsHttpConnection.cpp | 28 ++++++++++++++++------------
 netwerk/protocol/http/nsHttpConnection.h   |  2 ++
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp
index 824a5078e4eea..8b01fad1a12bf 100644
--- a/netwerk/protocol/http/nsHttpConnection.cpp
+++ b/netwerk/protocol/http/nsHttpConnection.cpp
@@ -840,6 +840,8 @@ void nsHttpConnection::Close(nsresult reason, bool aIsShutdown) {
   LOG(("nsHttpConnection::Close [this=%p reason=%" PRIx32 "]\n", this,
        static_cast<uint32_t>(reason)));
 
+  mClosed = true;
+
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
   mTlsHandshakeComplitionPending = false;
   mContinueHandshakeDone = nullptr;
@@ -2550,18 +2552,20 @@ bool nsHttpConnection::GetEchConfigUsed() {
 
 NS_IMETHODIMP
 nsHttpConnection::HandshakeDone() {
-  mTlsHandshakeComplitionPending = true;
-
-  // HandshakeDone needs to be dispatched so that it is not called inside
-  // nss locks.
-  RefPtr<nsHttpConnection> self(this);
-  NS_DispatchToCurrentThread(NS_NewRunnableFunction(
-      "nsHttpConnection::HandshakeDoneInternal", [self{std::move(self)}]() {
-        if (self->mTlsHandshakeComplitionPending) {
-          self->HandshakeDoneInternal();
-          self->mTlsHandshakeComplitionPending = false;
-        }
-      }));
+  if (!mClosed) {
+    mTlsHandshakeComplitionPending = true;
+
+    // HandshakeDone needs to be dispatched so that it is not called inside
+    // nss locks.
+    RefPtr<nsHttpConnection> self(this);
+    NS_DispatchToCurrentThread(NS_NewRunnableFunction(
+        "nsHttpConnection::HandshakeDoneInternal", [self{std::move(self)}]() {
+          if (self->mTlsHandshakeComplitionPending && !self->mClosed) {
+            self->HandshakeDoneInternal();
+            self->mTlsHandshakeComplitionPending = false;
+          }
+        }));
+  }
   return NS_OK;
 }
 
diff --git a/netwerk/protocol/http/nsHttpConnection.h b/netwerk/protocol/http/nsHttpConnection.h
index 85fbb6c9214c8..080487dca4165 100644
--- a/netwerk/protocol/http/nsHttpConnection.h
+++ b/netwerk/protocol/http/nsHttpConnection.h
@@ -390,6 +390,8 @@ class nsHttpConnection final : public HttpConnectionBase,
  private:
   bool mThroughCaptivePortal;
   int64_t mTotalBytesWritten = 0;  // does not include CONNECT tunnel
+
+  bool mClosed{false};
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsHttpConnection, NS_HTTPCONNECTION_IID)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list