Changeset 110699 in webkit


Ignore:
Timestamp:
Mar 14, 2012 8:02:14 AM (12 years ago)
Author:
abecsi@webkit.org
Message:

[Qt] RunLoopQt is missing reentrancy guards
https://bugs.webkit.org/show_bug.cgi?id=80982

Patch by Simon Hausmann <simon.hausmann@nokia.com> on 2012-03-14
Reviewed by Tor Arne Vestbø.

Avoid recursive calls to RunLoop::performWork() with a simple
counting mechanism, to avoid out-of-order message dispatching.

  • platform/qt/RunLoopQt.cpp:

(WebCore::RunLoop::TimerObject::TimerObject):
(WebCore::RunLoop::TimerObject::performWork):
(RunLoop::TimerObject):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r110698 r110699  
     12012-03-14  Simon Hausmann  <simon.hausmann@nokia.com>
     2
     3        [Qt] RunLoopQt is missing reentrancy guards
     4        https://bugs.webkit.org/show_bug.cgi?id=80982
     5
     6        Reviewed by Tor Arne Vestbø.
     7
     8        Avoid recursive calls to RunLoop::performWork() with a simple
     9        counting mechanism, to avoid out-of-order message dispatching.
     10
     11        * platform/qt/RunLoopQt.cpp:
     12        (WebCore::RunLoop::TimerObject::TimerObject):
     13        (WebCore::RunLoop::TimerObject::performWork):
     14        (RunLoop::TimerObject):
     15
    1162012-03-14  Ilya Tikhonovsky  <loislo@chromium.org>
    217
  • trunk/Source/WebCore/platform/qt/RunLoopQt.cpp

    r105475 r110699  
    4040    Q_OBJECT
    4141public:
    42     TimerObject(RunLoop* runLoop) : m_runLoop(runLoop)
     42    TimerObject(RunLoop* runLoop)
     43        : m_runLoop(runLoop)
     44        , m_pendingPerformWorkInvocations(0)
    4345    {
    4446        int methodIndex = metaObject()->indexOfMethod("performWork()");
     
    4648    }
    4749
    48     Q_SLOT void performWork() { m_runLoop->performWork(); }
     50    Q_SLOT void performWork() {
     51        // It may happen that a secondary thread adds more method invocations via
     52        // RunLoop::dispatch(), which will schedule a call to this function. If during
     53        // performWork() event loop messages get processed, it may happen that this
     54        // function is called again. In this case we should protected ourselves against
     55        // recursive - and thus out-of-order - message dispatching and instead perform
     56        // the work serially.
     57        m_pendingPerformWorkInvocations++;
     58        if (m_pendingPerformWorkInvocations > 1)
     59            return;
     60
     61        while (m_pendingPerformWorkInvocations) {
     62            m_runLoop->performWork();
     63            m_pendingPerformWorkInvocations--;
     64        }
     65    }
    4966    inline void wakeUp() { m_method.invoke(this, Qt::QueuedConnection); }
    5067
     
    5875    RunLoop* m_runLoop;
    5976    QMetaMethod m_method;
     77    int m_pendingPerformWorkInvocations;
    6078};
    6179
Note: See TracChangeset for help on using the changeset viewer.