bug 1441131 - TRR: proxy storage removal to the mainthread r=valentin
authorDaniel Stenberg <daniel@haxx.se>
Mon, 12 Mar 2018 15:57:13 +0100
changeset 766823 4660a81a0228d6d9b3c6063256cd4348ad1c142b
parent 766822 ce0bde354931425a042449771d1d81f54fa316b9
child 766824 8f1b2f872f0ea358a0412eb8b8687f08d47f6621
push id102399
push userbmo:mratcliffe@mozilla.com
push dateTue, 13 Mar 2018 10:12:19 +0000
reviewersvalentin
bugs1441131
milestone61.0a1
bug 1441131 - TRR: proxy storage removal to the mainthread r=valentin MozReview-Commit-ID: K4Ar0RbSRzS
netwerk/dns/TRRService.cpp
--- a/netwerk/dns/TRRService.cpp
+++ b/netwerk/dns/TRRService.cpp
@@ -430,18 +430,29 @@ TRRService::IsTRRBlacklisted(const nsACS
     nsresult code;
     int32_t until = val.ToInteger(&code) + mTRRBlacklistExpireTime;
     int32_t expire = NowInSeconds();
     if (NS_SUCCEEDED(code) && (until > expire)) {
       LOG(("Host [%s] is TRR blacklisted\n", nsCString(aHost).get()));
       return true;
     } else {
       // the blacklisted entry has expired
-      mTRRBLStorage->Remove(hashkey, privateBrowsing ?
-                            DataStorage_Private : DataStorage_Persistent);
+      RefPtr<DataStorage> storage = mTRRBLStorage;
+      nsCOMPtr<nsIRunnable> runnable =
+        NS_NewRunnableFunction("proxyStorageRemove",
+                               [storage, hashkey, privateBrowsing]() {
+                                 storage->Remove(hashkey, privateBrowsing ?
+                                                 DataStorage_Private :
+                                                 DataStorage_Persistent);
+                               });
+      if (!NS_IsMainThread()) {
+        NS_DispatchToMainThread(runnable);
+      } else {
+        runnable->Run();
+      }
     }
   }
   return false;
 }
 
 class ProxyBlacklist : public Runnable
 {
 public: