[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



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@xxxxxxxxx>
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.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits