Bug 1370448 - Start poll watchdog timer off of a runnable from the main thread in order to avoid a false positive detected deadlock; r=dragana
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 05 Jun 2017 16:58:52 -0400
changeset 413075 551c2fc04c72cb29ba18af90af2c4deac9261f21
parent 413074 e1409f1a455cc5a7f8f96463d6c2692a15c4a6af
child 413076 16798a4167a180349f1c566fad9bc87bcfd0e992
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1370448
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1370448 - Start poll watchdog timer off of a runnable from the main thread in order to avoid a false positive detected deadlock; r=dragana
netwerk/base/nsSocketTransportService2.cpp
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -1606,27 +1606,32 @@ nsSocketTransportService::GetSocketConne
     for (uint32_t i = 0; i < mIdleCount; i++)
         AnalyzeConnection(data, &mIdleList[i], false);
 }
 
 #if defined(XP_WIN)
 void
 nsSocketTransportService::StartPollWatchdog()
 {
-    MutexAutoLock lock(mLock);
+    // Start off the timer from a runnable off of the main thread in order to
+    // avoid a deadlock, see bug 1370448.
+    RefPtr<nsSocketTransportService> self(this);
+    NS_DispatchToMainThread(NS_NewRunnableFunction([self] {
+         MutexAutoLock lock(self->mLock);
 
-    // Poll can hang sometimes. If we are in shutdown, we are going to start a
-    // watchdog. If we do not exit poll within REPAIR_POLLABLE_EVENT_TIME
-    // signal a pollable event again.
-    MOZ_ASSERT(gIOService->IsNetTearingDown());
-    if (mPolling && !mPollRepairTimer) {
-        mPollRepairTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
-        mPollRepairTimer->Init(this, REPAIR_POLLABLE_EVENT_TIME,
-                               nsITimer::TYPE_REPEATING_SLACK);
-    }
+         // Poll can hang sometimes. If we are in shutdown, we are going to start a
+         // watchdog. If we do not exit poll within REPAIR_POLLABLE_EVENT_TIME
+         // signal a pollable event again.
+         MOZ_ASSERT(gIOService->IsNetTearingDown());
+         if (self->mPolling && !self->mPollRepairTimer) {
+             self->mPollRepairTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
+             self->mPollRepairTimer->Init(self, REPAIR_POLLABLE_EVENT_TIME,
+                                          nsITimer::TYPE_REPEATING_SLACK);
+         }
+    }));
 }
 
 void
 nsSocketTransportService::DoPollRepair()
 {
     MutexAutoLock lock(mLock);
     if (mPolling && mPollableEvent) {
         mPollableEvent->Signal();