mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 725885: Worker interval timers can be deleted prematurely. r=bent
--HG-- extra : rebase_source : 9588ec51cd18a7bf2ac3c07aa6ef0dfe50a01bef
This commit is contained in:
parent
565328e834
commit
adb43ca69b
@ -3700,7 +3700,11 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
|
||||
|
||||
NS_ASSERTION(!mTimeouts.Contains(info), "Shouldn't have duplicates!");
|
||||
|
||||
info->mTargetTime += info->mInterval;
|
||||
// NB: We must ensure that info->mTargetTime > now (where now is the
|
||||
// now above, not literally TimeStamp::Now()) or we will remove the
|
||||
// interval in the next loop below.
|
||||
info->mTargetTime = NS_MAX(info->mTargetTime + info->mInterval,
|
||||
now + TimeDuration::FromMilliseconds(1));
|
||||
mTimeouts.InsertElementSorted(info, comparator);
|
||||
}
|
||||
}
|
||||
@ -3712,6 +3716,8 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
|
||||
for (PRUint32 index = 0; index < mTimeouts.Length(); ) {
|
||||
nsAutoPtr<TimeoutInfo>& info = mTimeouts[index];
|
||||
if (info->mTargetTime <= now || info->mCanceled) {
|
||||
NS_ASSERTION(!info->mIsInterval || info->mCanceled,
|
||||
"Interval timers can only be removed when canceled!");
|
||||
mTimeouts.RemoveElement(info);
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user