From a8fed672cbcc170436d1f90ac698d721fcc725b4 Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Mon, 14 Sep 2020 09:27:42 +0000 Subject: [PATCH] Bug 1664020 - ShutdownEvent::PostAndWait should return immediately if posting the event fails r=necko-reviewers,kershaw Differential Revision: https://phabricator.services.mozilla.com/D89648 --- netwerk/cache2/CacheFileIOManager.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index 9dff05f13f91..5ffd12a9c071 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -544,12 +544,18 @@ class ShutdownEvent : public Runnable { void PostAndWait() { MonitorAutoLock mon(mMonitor); - DebugOnly rv; - rv = CacheFileIOManager::gInstance->mIOThread->Dispatch( + nsresult rv = CacheFileIOManager::gInstance->mIOThread->Dispatch( this, CacheIOThread::WRITE); // When writes and closing of handles is done MOZ_ASSERT(NS_SUCCEEDED(rv)); + // If we failed to post the even there's no reason to go into the loop + // because mNotified will never be set to true. + if (NS_FAILED(rv)) { + NS_WARNING("Posting ShutdownEvent task failed"); + return; + } + TimeDuration waitTime = TimeDuration::FromSeconds(1); while (!mNotified) { mon.Wait(waitTime);