Bug 1099209 - Only track leaked URLs on the main thread. r=honzab, a=sledru
authorValentin Gosu <valentin.gosu@gmail.com>
Tue, 31 Mar 2015 14:19:27 +0300
changeset 265495 1d66ed2ccb3c850d65ed27645d12aaea438fecd5
parent 265494 8950cd69d6e39267503305d84c1b6872913e42f4
child 265496 a5e2ccf127b8dac12961602ff4fed747103825ce
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab, sledru
bugs1099209
milestone39.0a2
Bug 1099209 - Only track leaked URLs on the main thread. r=honzab, a=sledru
netwerk/base/nsStandardURL.cpp
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -266,46 +266,51 @@ nsStandardURL::nsStandardURL(bool aSuppo
         gInitialized = true;
         InitGlobalObjects();
     }
 
     // default parser in case nsIStandardURL::Init is never called
     mParser = net_GetStdURLParser();
 
 #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
-    if (aTrackURL) {
-        PR_APPEND_LINK(&mDebugCList, &gAllURLs);
-    } else {
-        PR_INIT_CLIST(&mDebugCList);
+    if (NS_IsMainThread()) {
+        if (aTrackURL) {
+            PR_APPEND_LINK(&mDebugCList, &gAllURLs);
+        } else {
+            PR_INIT_CLIST(&mDebugCList);
+        }
     }
 #endif
 }
 
 nsStandardURL::~nsStandardURL()
 {
     LOG(("Destroying nsStandardURL @%p\n", this));
 
     if (mHostA) {
         free(mHostA);
     }
 #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
-    if (!PR_CLIST_IS_EMPTY(&mDebugCList)) {
-        PR_REMOVE_LINK(&mDebugCList);
+    if (NS_IsMainThread()) {
+        if (!PR_CLIST_IS_EMPTY(&mDebugCList)) {
+            PR_REMOVE_LINK(&mDebugCList);
+        }
     }
 #endif
 }
 
 #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
 struct DumpLeakedURLs {
     DumpLeakedURLs() {}
     ~DumpLeakedURLs();
 };
 
 DumpLeakedURLs::~DumpLeakedURLs()
 {
+    MOZ_ASSERT(NS_IsMainThread());
     if (!PR_CLIST_IS_EMPTY(&gAllURLs)) {
         printf("Leaked URLs:\n");
         for (PRCList *l = PR_LIST_HEAD(&gAllURLs); l != &gAllURLs; l = PR_NEXT_LINK(l)) {
             nsStandardURL *url = reinterpret_cast<nsStandardURL*>(reinterpret_cast<char*>(l) - offsetof(nsStandardURL, mDebugCList));
             url->PrintSpec();
         }
     }
 }