⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 284681 in webkit


Ignore:
Timestamp:
Oct 22, 2021, 7:38:42 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

StreamConnectionWorkQueue::processStreams() has a incorrect protection ref
https://bugs.webkit.org/show_bug.cgi?id=232070

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-10-22
Reviewed by Wenson Hsieh.

  • GPUProcess/graphics/RemoteRenderingBackend.cpp:

(WebKit::RemoteRenderingBackend::~RemoteRenderingBackend):
Additionally remove redundant protection ref from RemoteRenderingBackend
cleanup task. Since m_workQueue->stop() is run after dispatching the
task, and since stop() waits until queue has executed the
all the tasks, the m_workQueue ref outlives the protection ref.

  • Platform/IPC/StreamConnectionWorkQueue.cpp:

(IPC::StreamConnectionWorkQueue::processStreams):
Remove the redundant protection ref so it does not cause confusion.
The protection ref cannot hold the last ref, as that would mean
that the StreamConnectionWorkQueue thread would run the code to
destroy the work queue itself. There has to be a external ref for
queue->stop() that outlives the protection ref, as the stop() will
wait until the queue thread stops.

(IPC::StreamConnectionWorkQueue::stopAndWaitForCompletion):
(IPC::StreamConnectionWorkQueue::stop): Deleted.

  • Platform/IPC/StreamConnectionWorkQueue.h:

Rename stop() to stopAndWaitForCompletion() to signify what
the function does.

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r284679 r284681  
     12021-10-22  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        StreamConnectionWorkQueue::processStreams() has a incorrect protection ref
     4        https://bugs.webkit.org/show_bug.cgi?id=232070
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
     9        (WebKit::RemoteRenderingBackend::~RemoteRenderingBackend):
     10        Additionally remove redundant protection ref from `RemoteRenderingBackend`
     11        cleanup task. Since `m_workQueue->stop()` is run after dispatching the
     12        task, and since `stop()` waits until queue has executed the
     13        all the tasks, the `m_workQueue` ref outlives the protection ref.
     14
     15        * Platform/IPC/StreamConnectionWorkQueue.cpp:
     16        (IPC::StreamConnectionWorkQueue::processStreams):
     17        Remove the redundant protection ref so it does not cause confusion.
     18        The protection ref cannot hold the last ref, as that would mean
     19        that the `StreamConnectionWorkQueue` thread would run the code to
     20        destroy the work queue itself. There has to be a external ref for
     21        `queue->stop()` that outlives the protection ref, as the `stop()` will
     22        wait until the queue thread stops.
     23
     24        (IPC::StreamConnectionWorkQueue::stopAndWaitForCompletion):
     25        (IPC::StreamConnectionWorkQueue::stop): Deleted.
     26        * Platform/IPC/StreamConnectionWorkQueue.h:
     27        Rename `stop()` to `stopAndWaitForCompletion()` to signify what
     28        the function does.
     29
    1302021-10-22  Alberto Garcia  <berto@igalia.com>
    231
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp

    r284476 r284681  
    9999    // Make sure we destroy the ResourceCache on the WorkQueue since it gets populated on the WorkQueue.
    100100    // Make sure rendering resource request is released after destroying the cache.
    101     m_workQueue->dispatch([workQueue = m_workQueue.copyRef(), renderingResourcesRequest = WTFMove(m_renderingResourcesRequest), remoteResourceCache = WTFMove(m_remoteResourceCache)] { });
    102     m_workQueue->stop();
     101    m_workQueue->dispatch([renderingResourcesRequest = WTFMove(m_renderingResourcesRequest), remoteResourceCache = WTFMove(m_remoteResourceCache)] { });
     102    m_workQueue->stopAndWaitForCompletion();
    103103}
    104104
  • trunk/Source/WebKit/Platform/IPC/StreamConnectionWorkQueue.cpp

    r284671 r284681  
    3636StreamConnectionWorkQueue::~StreamConnectionWorkQueue()
    3737{
    38     // `StreamConnectionWorkQueue::stop()` should be called if anything has been dispatched or listened to.
     38    // `StreamConnectionWorkQueue::stopAndWaitForCompletion()` should be called if anything has been dispatched or listened to.
    3939    ASSERT(!m_processingThread);
    4040}
     
    7676}
    7777
    78 void StreamConnectionWorkQueue::stop()
     78void StreamConnectionWorkQueue::stopAndWaitForCompletion()
    7979{
    8080    m_shouldQuit = true;
     
    118118void StreamConnectionWorkQueue::processStreams()
    119119{
    120     Ref protectedThis = *this;
    121120    constexpr size_t defaultMessageLimit = 1000;
    122121    bool hasMoreToProcess = false;
  • trunk/Source/WebKit/Platform/IPC/StreamConnectionWorkQueue.h

    r284671 r284681  
    5050
    5151    void dispatch(WTF::Function<void()>&&) final;
    52     void stop();
     52    void stopAndWaitForCompletion();
    5353
    5454    void wakeUp();
Note: See TracChangeset for help on using the changeset viewer.