Bug 1342887 - Detect and log failures to dispatch SetupMacCommandLine to the main thread. r=rstrong
authorMatt Howell <mhowell@mozilla.com>
Mon, 27 Feb 2017 13:57:11 -0800
changeset 374136 3120e572493a77518e6960898f34afb9e0268f5b
parent 374135 6e181ffefa618670a57a1a556afcd8a98b3fd8d5
child 374137 096a249febe7ff89b3d69fe7ff82a211fae57053
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs1342887
milestone54.0a1
Bug 1342887 - Detect and log failures to dispatch SetupMacCommandLine to the main thread. r=rstrong MozReview-Commit-ID: LMoxF5yfXq2
toolkit/xre/nsUpdateDriver.cpp
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -103,24 +103,34 @@ UpdateDriverSetupMacCommandLine(int& arg
   // Bug 1335916: SetupMacCommandLine calls a CoreFoundation function that
   // asserts that it was called from the main thread, so if we are not the main
   // thread, we have to dispatch that call to there. But we also have to get the
   // result from it, so we can't just dispatch and return, we have to wait
   // until the dispatched operation actually completes. So we also set up a
   // monitor to signal us when that happens, and block until then.
   Monitor monitor("nsUpdateDriver SetupMacCommandLine");
 
-  NS_DispatchToMainThread(
+  nsresult rv = NS_DispatchToMainThread(
     NS_NewRunnableFunction([&argc, &argv, restart, &monitor]() -> void
     {
       CommandLineServiceMac::SetupMacCommandLine(argc, argv, restart);
       MonitorAutoLock(monitor).Notify();
     }));
 
-  MonitorAutoLock(monitor).Wait();
+  if (NS_FAILED(rv)) {
+    LOG(("Update driver error dispatching SetupMacCommandLine to main thread: %d\n", rv));
+    return;
+  }
+
+  // The length of this wait is arbitrary, but should be long enough that having
+  // it expire means something is seriously wrong.
+  rv = MonitorAutoLock(monitor).Wait(PR_SecondsToInterval(60));
+  if (NS_FAILED(rv)) {
+    LOG(("Update driver timed out waiting for SetupMacCommandLine: %d\n", rv));
+  }
 }
 #endif
 
 static nsresult
 GetCurrentWorkingDir(char *buf, size_t size)
 {
   // Cannot use NS_GetSpecialDirectory because XPCOM is not yet initialized.
   // This code is duplicated from xpcom/io/SpecialSystemDirectory.cpp: