Delete the previous timer-queue timer in the main thread, just prior to sched...
authorsfalken@apple.com <sfalken@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Dec 2008 18:10:52 +0000 (18:10 +0000)
committersfalken@apple.com <sfalken@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Dec 2008 18:10:52 +0000 (18:10 +0000)
commitaf449749d89588083bb797f19bc187e938c45ea1
treeb1a205ae13cd3d51adb32563bcd338b02f230185
parentf0f6dad7ba73662dc5296670249c9702ba89356e
    Delete the previous timer-queue timer in the main thread, just prior to scheduling a new timer.
        The code previously called DeleteTimerQueueTimer in the timer callback proc.

        The new technique simplifies the code, since we now create and delete timers on the
        same thread, and don't access the timer queue or timer handles in the callback.
        This allows us to remove some mutex use, and more importantly, it solves a race
        condition that was occuring between ChangeTimerQueueTimer and DeleteTimerQueueTimer.

        Since the timer callback isn't passed the timer handle, we were retrieving that handle
        via a global. If the timer callback code was entered, but then a new timer was immediately
        scheduled (prior to the callback acquiring the mutex and calling DeleteTimerQueueTimer),
        there was a small window where the timer could be re-scheduled via ChangeTimerQueueTimer
        and then immediately deleted once the already running callback acquired the mutex and
        then called DeleteTimerQueueTimer. This resulted in the newly scheduled timer never firing.

        Reviewed by Oliver Hunt.

        * platform/win/SharedTimerWin.cpp:
        (WebCore::queueTimerProc): Don't delete the timer in the callback.
        (WebCore::setSharedTimerFireTime): Always delete and create the timer instead of using ChangeTimerQueueTimer.
        (WebCore::stopSharedTimer): Call DeleteTimerQueueTimer directly.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39247 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebCore/ChangeLog
WebCore/platform/win/SharedTimerWin.cpp