From ba8c46feca1fdcc37eff190513094309d2f61e36 Mon Sep 17 00:00:00 2001 From: Matt Howell Date: Mon, 27 Feb 2017 13:57:11 -0800 Subject: [PATCH] Bug 1342887 - Detect and log failures to dispatch SetupMacCommandLine to the main thread. r=rstrong MozReview-Commit-ID: LMoxF5yfXq2 --HG-- extra : rebase_source : c206e32bf8abf1aa225901ff5cde390a8a2ecec7 --- toolkit/xre/nsUpdateDriver.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp index efb381bc918f..e702f7a28ed5 100644 --- a/toolkit/xre/nsUpdateDriver.cpp +++ b/toolkit/xre/nsUpdateDriver.cpp @@ -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