Bug 1332402 - Part 2: just complain if SingletonThread is still active at shutdown r=bwc draft
authorRandell Jesup <rjesup@jesup.org>
Thu, 19 Jan 2017 15:07:47 -0500
changeset 464255 87d10a7c546f6f85f8e2c769e20afcc63ea724ef
parent 464254 388fac2352fc5a7e83b91e7b011358458171e9a7
child 542893 af4e16f925b8a4ab63ec6b596d20fb9c2155dc63
push id42321
push userbcampen@mozilla.com
push dateFri, 20 Jan 2017 19:39:15 +0000
reviewersbwc
bugs1332402
milestone53.0a1
Bug 1332402 - Part 2: just complain if SingletonThread is still active at shutdown r=bwc MozReview-Commit-ID: B57cZnCuAdv
media/mtransport/nr_socket_prsock.cpp
--- a/media/mtransport/nr_socket_prsock.cpp
+++ b/media/mtransport/nr_socket_prsock.cpp
@@ -109,16 +109,17 @@ nrappkit copyright:
 #include "runnable_utils.h"
 #include "mozilla/SyncRunnable.h"
 #include "nsTArray.h"
 #include "mozilla/dom/TCPSocketBinding.h"
 #include "nsITCPSocketCallback.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsISocketFilter.h"
+#include "nsDebug.h"
 
 #ifdef XP_WIN
 #include "mozilla/WindowsVersion.h"
 #endif
 
 #if defined(MOZILLA_INTERNAL_API)
 // csi_platform.h deep in nrappkit defines LOG_INFO and LOG_WARNING
 #ifdef LOG_INFO
@@ -173,18 +174,19 @@ namespace mozilla {
 
 #if defined(MOZILLA_INTERNAL_API)
 class SingletonThreadHolder final
 {
 private:
   ~SingletonThreadHolder()
   {
     r_log(LOG_GENERIC,LOG_DEBUG,"Deleting SingletonThreadHolder");
-    MOZ_ASSERT(!mThread, "SingletonThreads should be Released and shut down before exit!");
     if (mThread) {
+      // Likely a connection is somehow being held in CC or GC
+      NS_WARNING("SingletonThreads should be Released and shut down before exit!");
       mThread->Shutdown();
       mThread = nullptr;
     }
   }
 
   DISALLOW_COPY_ASSIGN(SingletonThreadHolder);
 
 public:
@@ -246,17 +248,17 @@ private:
   nsCOMPtr<nsIThread> mParentThread;
   nsCOMPtr<nsIThread> mThread;
 };
 
 static StaticRefPtr<SingletonThreadHolder> sThread;
 
 static void ClearSingletonOnShutdown()
 {
-  ClearOnShutdown(&sThread);
+  ClearOnShutdown(&sThread, ShutdownPhase::ShutdownThreads);
 }
 #endif
 
 static nsIThread* GetIOThreadAndAddUse_s()
 {
   // Always runs on STS thread!
 #if defined(MOZILLA_INTERNAL_API)
   // We need to safely release this on shutdown to avoid leaks