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 258407 58dca3f7560a
parent 258406 367745bbac8a
child 258408 d13016a31d6f
push id4659
push userryanvm@gmail.com
push date2015-04-09 15:23 +0000
treeherdermozilla-beta@58dca3f7560a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab, sledru
bugs1099209
milestone38.0
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();
         }
     }
 }