From ada35c9a531e1bcb4f5fd3e16ad8c520a7f3c225 Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" Date: Tue, 14 Feb 2017 15:29:01 -0600 Subject: [PATCH] Bug 1339588 - Part 1: Simplify nsTimerEvent::Cancel, since there's no need to release the nsTimerImpl itself. r=froydnj MozReview-Commit-ID: 6br6DaDqxR0 --HG-- extra : rebase_source : 13cde860824483332c42ac2f86bca722bf42d36b extra : source : 47a3ac382469cb8bd4cdfa123457a6d6b4f11d39 --- xpcom/threads/TimerThread.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/xpcom/threads/TimerThread.cpp b/xpcom/threads/TimerThread.cpp index f65c9deead24..93b378b88e71 100644 --- a/xpcom/threads/TimerThread.cpp +++ b/xpcom/threads/TimerThread.cpp @@ -141,11 +141,7 @@ public: nsresult Cancel() override { - // Since nsTimerImpl is not thread-safe, we should release |mTimer| - // here in the target thread to avoid race condition. Otherwise, - // ~nsTimerEvent() which calls nsTimerImpl::Release() could run in the - // timer thread and result in race condition. - mTimer = nullptr; + mTimer->Cancel(); return NS_OK; } @@ -282,11 +278,6 @@ nsTimerEvent::GetName(nsACString& aName) NS_IMETHODIMP nsTimerEvent::Run() { - if (!mTimer) { - MOZ_ASSERT(false); - return NS_OK; - } - if (MOZ_LOG_TEST(GetTimerLog(), LogLevel::Debug)) { TimeStamp now = TimeStamp::Now(); MOZ_LOG(GetTimerLog(), LogLevel::Debug, @@ -296,9 +287,7 @@ nsTimerEvent::Run() mTimer->Fire(mGeneration); - // We call Cancel() to correctly release mTimer. - // Read more in the Cancel() implementation. - return Cancel(); + return NS_OK; } nsresult