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

Changeset 184072 in webkit


Ignore:
Timestamp:
May 11, 2015, 3:21:40 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] WorkQueue objects are not released
https://bugs.webkit.org/show_bug.cgi?id=144824

Reviewed by Žan Doberšek.

Do not keep a reference of the WorkQueue for the entire life of
its worker thread, since every task scheduled on the WorkQueue
already takes a reference. Instead, take a reference of the main
loop to make sure that when the worker thread starts, the main
loop hasn't been released to avoid runtime warnings (see
webkit.org/b/140998). Also removed the g_main_context_pop_thread_default()
from the thread body, since the thread-specific context queue will
be freed anyway when the thread exits.
If the WorkQueue is released early, before the thread has started,
schedule a main loop quit in the context, to make sure it will
be the first thing run by the main loop and the thread will exit.

  • wtf/WorkQueue.h: Remove unused event loop mutex.
  • wtf/gtk/WorkQueueGtk.cpp:

(WTF::WorkQueue::platformInitialize):
(WTF::WorkQueue::platformInvalidate):

Location:
trunk/Source/WTF
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r184040 r184072  
     12015-05-11  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] WorkQueue objects are not released
     4        https://bugs.webkit.org/show_bug.cgi?id=144824
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Do not keep a reference of the WorkQueue for the entire life of
     9        its worker thread, since every task scheduled on the WorkQueue
     10        already takes a reference. Instead, take a reference of the main
     11        loop to make sure that when the worker thread starts, the main
     12        loop hasn't been released to avoid runtime warnings (see
     13        webkit.org/b/140998). Also removed the g_main_context_pop_thread_default()
     14        from the thread body, since the thread-specific context queue will
     15        be freed anyway when the thread exits.
     16        If the WorkQueue is released early, before the thread has started,
     17        schedule a main loop quit in the context, to make sure it will
     18        be the first thing run by the main loop and the thread will exit.
     19
     20        * wtf/WorkQueue.h: Remove unused event loop mutex.
     21        * wtf/gtk/WorkQueueGtk.cpp:
     22        (WTF::WorkQueue::platformInitialize):
     23        (WTF::WorkQueue::platformInvalidate):
     24
    1252015-05-09  Yoav Weiss  <yoav@yoav.ws>
    226
  • trunk/Source/WTF/wtf/WorkQueue.h

    r183746 r184072  
    107107    ThreadIdentifier m_workQueueThread;
    108108    GRefPtr<GMainContext> m_eventContext;
    109     Mutex m_eventLoopLock;
    110109    GRefPtr<GMainLoop> m_eventLoop;
    111110    GMainLoopSource m_socketEventSource;
  • trunk/Source/WTF/wtf/gtk/WorkQueueGtk.cpp

    r183800 r184072  
    5656        threadName += strlen(threadName) - kVisualStudioThreadNameLimit;
    5757
    58     RefPtr<WorkQueue> protector(this);
    59     m_workQueueThread = createThread(threadName, [protector] {
    60         g_main_context_push_thread_default(protector->m_eventContext.get());
    61         g_main_loop_run(protector->m_eventLoop.get());
    62         g_main_context_pop_thread_default(protector->m_eventContext.get());
     58    GRefPtr<GMainLoop> eventLoop(m_eventLoop.get());
     59    m_workQueueThread = createThread(threadName, [eventLoop] {
     60        g_main_context_push_thread_default(g_main_loop_get_context(eventLoop.get()));
     61        g_main_loop_run(eventLoop.get());
    6362    });
    6463}
     
    7170    }
    7271
    73     MutexLocker locker(m_eventLoopLock);
    7472    if (m_eventLoop) {
    7573        if (g_main_loop_is_running(m_eventLoop.get()))
    7674            g_main_loop_quit(m_eventLoop.get());
    77         m_eventLoop.clear();
     75        else {
     76            // The thread hasn't started yet, so schedule a main loop quit to ensure the thread finishes.
     77            GMainLoop* eventLoop = m_eventLoop.get();
     78            GMainLoopSource::scheduleAndDeleteOnDestroy("[WebKit] WorkQueue quit main loop", [eventLoop] { g_main_loop_quit(eventLoop); },
     79                G_PRIORITY_HIGH, nullptr, m_eventContext.get());
     80        }
     81        m_eventLoop = nullptr;
    7882    }
    7983
    80     m_eventContext.clear();
     84    m_eventContext = nullptr;
    8185}
    8286
Note: See TracChangeset for help on using the changeset viewer.