зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1059572 - Part 2: Make absolutely sure a timer is removed before reinitting it. r=nfroyd
--HG-- extra : rebase_source : 9a952241e046321a25adf52167bd7a538d25f37a
This commit is contained in:
Родитель
e145322168
Коммит
309a57122b
|
@ -205,23 +205,7 @@ nsTimerImpl::InitCommon(uint32_t aType, uint32_t aDelay)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* In case of re-Init, both with and without a preceding Cancel, clear the
|
|
||||||
* mCanceled flag and assign a new mGeneration. But first, remove any armed
|
|
||||||
* timer from the timer thread's list.
|
|
||||||
*
|
|
||||||
* If we are racing with the timer thread to remove this timer and we lose,
|
|
||||||
* the RemoveTimer call made here will fail to find this timer in the timer
|
|
||||||
* thread's list, and will return false harmlessly. We test mArmed here to
|
|
||||||
* avoid the small overhead in RemoveTimer of locking the timer thread and
|
|
||||||
* checking its list for this timer. It's safe to test mArmed even though
|
|
||||||
* it might be cleared on another thread in the next cycle (or even already
|
|
||||||
* be cleared by another CPU whose store hasn't reached our CPU's cache),
|
|
||||||
* because RemoveTimer is idempotent.
|
|
||||||
*/
|
|
||||||
if (mArmed) {
|
|
||||||
gThread->RemoveTimer(this);
|
gThread->RemoveTimer(this);
|
||||||
}
|
|
||||||
mCanceled = false;
|
mCanceled = false;
|
||||||
mTimeout = TimeStamp();
|
mTimeout = TimeStamp();
|
||||||
mGeneration = gGenerator++;
|
mGeneration = gGenerator++;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче