[tor-commits] [tor-browser] 17/73: Bug 1779005 - Avoid setting |mLoader| to null if we already start a new PAC load, r=necko-reviewers, valentin a=RyanVM

gitolite role git at cupani.torproject.org
Wed Sep 21 20:17:10 UTC 2022


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

richard pushed a commit to branch geckoview-102.3.0esr-12.0-1
in repository tor-browser.

commit a8420e6d329c80d03df68edf03fb20947953baad
Author: Kershaw Chang <kershaw at mozilla.com>
AuthorDate: Thu Aug 11 13:51:52 2022 +0000

    Bug 1779005 - Avoid setting |mLoader| to null if we already start a new PAC load, r=necko-reviewers,valentin a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D154368
---
 netwerk/base/nsPACMan.cpp | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/netwerk/base/nsPACMan.cpp b/netwerk/base/nsPACMan.cpp
index f36940eab3f8e..63908e1cf0773 100644
--- a/netwerk/base/nsPACMan.cpp
+++ b/netwerk/base/nsPACMan.cpp
@@ -712,13 +712,6 @@ void nsPACMan::ContinueLoadingAfterPACUriKnown() {
 }
 
 void nsPACMan::OnLoadFailure() {
-  // We have to clear the loader to indicate that we are not loading PAC
-  // currently.
-  {
-    auto loader = mLoader.Lock();
-    loader.ref() = nullptr;
-  }
-
   int32_t minInterval = 5;    // 5 seconds
   int32_t maxInterval = 300;  // 5 minutes
 
@@ -875,6 +868,7 @@ nsPACMan::OnStreamComplete(nsIStreamLoader* loader, nsISupports* context,
                            const uint8_t* data) {
   MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
 
+  bool loadSucceeded = NS_SUCCEEDED(status) && HttpRequestSucceeded(loader);
   {
     auto locked = mLoader.Lock();
     if (locked.ref() != loader) {
@@ -883,13 +877,21 @@ nsPACMan::OnStreamComplete(nsIStreamLoader* loader, nsISupports* context,
       // should be NS_ERROR_ABORT, and if so, then we know that we can and
       // should delay any processing.
       LOG(("OnStreamComplete: called more than once\n"));
-      if (status == NS_ERROR_ABORT) return NS_OK;
+      if (status == NS_ERROR_ABORT) {
+        return NS_OK;
+      }
+    } else if (!loadSucceeded) {
+      // We have to clear the loader to indicate that we are not loading PAC
+      // currently.
+      // Note that we can only clear the loader when |loader| and |mLoader| are
+      // the same one.
+      locked.ref() = nullptr;
     }
   }
 
   LOG(("OnStreamComplete: entry\n"));
 
-  if (NS_SUCCEEDED(status) && HttpRequestSucceeded(loader)) {
+  if (loadSucceeded) {
     // Get the URI spec used to load this PAC script.
     nsAutoCString pacURI;
     {

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


More information about the tor-commits mailing list