bug 1441131 - TRR: proxy storage removal to the mainthread r?valentin draft
authorDaniel Stenberg <daniel@haxx.se>
Mon, 12 Mar 2018 15:57:13 +0100
changeset 766624 330c5631c89fb1b19c34e62e7327b691bc73b29e
parent 766174 fdd1a0082c71673239fc2f3a6a93de889c07a1be
push id102373
push userbmo:daniel@haxx.se
push dateTue, 13 Mar 2018 06:33:15 +0000
reviewersvalentin
bugs1441131
milestone60.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
@@ -406,18 +406,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: