Commit a5fb96ad authored by Matt Howell's avatar Matt Howell Committed by Georg Koppen
Browse files

Bug 1342887 - Detect and log failures to dispatch SetupMacCommandLine to the main thread. r=rstrong

MozReview-Commit-ID: LMoxF5yfXq2

--HG--
extra : rebase_source : c206e32bf8abf1aa225901ff5cde390a8a2ecec7
parent 69a4e82c
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -108,14 +108,24 @@ UpdateDriverSetupMacCommandLine(int& argc, char**& argv, bool restart)
  // 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