<http://webkit.org/b/68809> IconDatabase::syncThreadMainLoop can assert if wakeSyncTh...
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Sep 2011 17:36:19 +0000 (17:36 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Sep 2011 17:36:19 +0000 (17:36 +0000)
If wakeSyncThread is called before syncThreadMainLoop starts executing then m_syncThreadHasWorkToDo would be set
while executing the body of the sync thread loop, causing us to skip blocking on the condition variable. This would
lead to us hitting the assertion failure due to m_disabledSuddenTerminationForSyncThread being false, unless the main
thread happened to call wakeSyncThread a second time while the first loop iteration was executing.

Reviewed by Anders Carlsson.

* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::syncThreadMainLoop): Clear m_syncThreadHasWorkToDo to indicate that we're about to perform
all pending work.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95961 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/loader/icon/IconDatabase.cpp

index 552e2ee..19f0f40 100644 (file)
@@ -1,3 +1,18 @@
+2011-09-26  Mark Rowe  <mrowe@apple.com>
+
+        <http://webkit.org/b/68809> IconDatabase::syncThreadMainLoop can assert if wakeSyncThread is called before thread starts executing
+
+        If wakeSyncThread is called before syncThreadMainLoop starts executing then m_syncThreadHasWorkToDo would be set
+        while executing the body of the sync thread loop, causing us to skip blocking on the condition variable. This would
+        lead to us hitting the assertion failure due to m_disabledSuddenTerminationForSyncThread being false, unless the main
+        thread happened to call wakeSyncThread a second time while the first loop iteration was executing.
+
+        Reviewed by Anders Carlsson.
+
+        * loader/icon/IconDatabase.cpp:
+        (WebCore::IconDatabase::syncThreadMainLoop): Clear m_syncThreadHasWorkToDo to indicate that we're about to perform
+        all pending work.
+
 2011-09-26  Antaryami Pandia  <antaryami.pandia@motorola.com>
 
         Groove/inset/outset borders show solid if the color is black.
index 5ee6f90..e863055 100644 (file)
@@ -1357,6 +1357,10 @@ void* IconDatabase::syncThreadMainLoop()
     bool shouldReenableSuddenTermination = m_disabledSuddenTerminationForSyncThread;
     m_disabledSuddenTerminationForSyncThread = false;
 
+    // We'll either do any pending work on our first pass through the loop, or we'll terminate
+    // without doing any work. Either way we're dealing with any currently-pending work.
+    m_syncThreadHasWorkToDo = false;
+
     // It's possible thread termination is requested before the main loop even starts - in that case, just skip straight to cleanup
     while (!m_threadTerminationRequested) {
         m_syncLock.unlock();