Changeset 38850 in webkit


Ignore:
Timestamp:
Nov 30, 2008 12:31:11 AM (15 years ago)
Author:
ap@webkit.org
Message:

Reviewed by Dan Bernstein.

https://bugs.webkit.org/show_bug.cgi?id=22530
Assertion failures seen on buildbot due to uninitialized WorkerThread::m_threadID

  • dom/WorkerThread.cpp: (WebCore::WorkerThread::start): Protect worker startup with a mutex to ensure that this function runs to completion before the thread begins execution. (WebCore::WorkerThread::workerThread): Updated comments. (WebCore::WorkerThread::stop): Ditto.
  • dom/WorkerThread.h: Renamed m_workerContextMutex to m_threadCreationMutex, because it now protects startup as a whole.
  • storage/DatabaseThread.cpp:
  • storage/DatabaseThread.h:
  • storage/LocalStorageThread.cpp:
  • storage/LocalStorageThread.h: Fixed the same m_threadID problem.
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r38847 r38850  
     12008-11-30  Alexey Proskuryakov  <ap@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=22530
     6        Assertion failures seen on buildbot due to uninitialized WorkerThread::m_threadID
     7
     8        * dom/WorkerThread.cpp:
     9        (WebCore::WorkerThread::start): Protect worker startup with a mutex to ensure that this
     10        function runs to completion before the thread begins execution.
     11        (WebCore::WorkerThread::workerThread): Updated comments.
     12        (WebCore::WorkerThread::stop): Ditto.
     13        * dom/WorkerThread.h: Renamed m_workerContextMutex to m_threadCreationMutex, because it now
     14        protects startup as a whole.
     15
     16        * storage/DatabaseThread.cpp:
     17        * storage/DatabaseThread.h:
     18        * storage/LocalStorageThread.cpp:
     19        * storage/LocalStorageThread.h:
     20        Fixed the same m_threadID problem.
     21
    1222008-11-29  Brent Fulgham  <bfulgham@gmail.com>
    223
  • trunk/WebCore/dom/WorkerThread.cpp

    r38746 r38850  
    6060bool WorkerThread::start()
    6161{
     62    // Mutex protection is necessary to ensure that m_threadID is initialized when the thread starts.
     63    MutexLocker lock(m_threadCreationMutex);
     64
    6265    if (m_threadID)
    6366        return true;
     
    7679{
    7780    {
    78         // Mutex protection is necessary because stop() can be called before the context is fully created.
    79         MutexLocker lock(m_workerContextMutex);
     81        MutexLocker lock(m_threadCreationMutex);
    8082        m_workerContext = WorkerContext::create(m_scriptURL, this);
    8183    }
     
    106108void WorkerThread::stop()
    107109{
    108     MutexLocker lock(m_workerContextMutex);
     110    // Mutex protection is necessary because stop() can be called before the context is fully created.
     111    MutexLocker lock(m_threadCreationMutex);
     112
    109113    // Ensure that tasks are being handled by thread event loop. If script execution weren't forbidden, a while(1) loop in JS could keep the thread alive forever.
    110114    if (m_workerContext)
  • trunk/WebCore/dom/WorkerThread.h

    r38729 r38850  
    6666
    6767        RefPtr<WorkerContext> m_workerContext;
    68         Mutex m_workerContextMutex;
     68        Mutex m_threadCreationMutex;
    6969
    7070        MessageQueue<RefPtr<WorkerTask> > m_messageQueue;
  • trunk/WebCore/storage/DatabaseThread.cpp

    r35419 r38850  
    4949bool DatabaseThread::start()
    5050{
     51    MutexLocker lock(m_threadCreationMutex);
     52
    5153    if (m_threadID)
    5254        return true;
     
    7678void* DatabaseThread::databaseThread()
    7779{
    78     LOG(StorageAPI, "Starting DatabaseThread %p", this);
     80    {
     81        // Wait for DatabaseThread::start() to complete.
     82        MutexLocker lock(m_threadCreationMutex);
     83        LOG(StorageAPI, "Started DatabaseThread %p", this);
     84    }
    7985
    8086    AutodrainedPool pool;
  • trunk/WebCore/storage/DatabaseThread.h

    r31971 r38850  
    3535#include <wtf/PassRefPtr.h>
    3636#include <wtf/RefPtr.h>
     37#include <wtf/Threading.h>
    3738
    3839namespace WebCore {
     
    6263    void* databaseThread();
    6364
     65    Mutex m_threadCreationMutex;
    6466    ThreadIdentifier m_threadID;
    6567    RefPtr<DatabaseThread> m_selfRef;
  • trunk/WebCore/storage/LocalStorageThread.cpp

    r35419 r38850  
    4646bool LocalStorageThread::start()
    4747{
     48    MutexLocker lock(m_threadCreationMutex);
     49
    4850    if (m_threadID)
    4951        return true;
     
    6163void* LocalStorageThread::localStorageThread()
    6264{
     65    {
     66        // Wait for LocalStorageThread::start() to complete.
     67        MutexLocker lock(m_threadCreationMutex);
     68    }
     69
    6370    while (true) {
    6471        RefPtr<LocalStorageTask> task;
  • trunk/WebCore/storage/LocalStorageThread.h

    r32918 r38850  
    6060        void* localStorageThread();
    6161
     62        Mutex m_threadCreationMutex;
    6263        ThreadIdentifier m_threadID;
    6364        RefPtr<LocalStorageThread> m_selfRef;
Note: See TracChangeset for help on using the changeset viewer.