> Prevent race condition during Worker shutdown
> Reviewed by Dmitry Titov.
> During worker shutdown, from the main thread a cleanup task is posted followed by
> terminating the message queue, which prevents further tasks from being processed. It was
> possible for another task be posted by another thread between the main thread calls
> to postTask and terminate(), which would cause that task to run after cleanup. Expose
> a new WTF::MessageQueue::appendAndKill() method which keeps a mutex around the two steps,
> and use that during worker shutdown.
> No reliable tests for the race - problem identified by inspection of user crash stacks.
> * workers/WorkerRunLoop.cpp:
> (WebCore::WorkerRunLoop::postTaskAndTerminate): New method, uses MessageQueue::appendAndKill()
> * workers/WorkerRunLoop.h:
> * workers/WorkerThread.cpp:
> (WebCore::WorkerThread::stop): Uses postTaskAndTerminate() to avoid race.
> Add MessageQueue::appendAndKill() which wraps those two steps with a mutex so other
> threads can't sneak a message in between.
> * wtf/MessageQueue.h: Added appendAndKill() method.