Title: [133307] trunk/Source/WebKit2
Revision
133307
Author
commit-qu...@webkit.org
Date
2012-11-02 09:30:24 -0700 (Fri, 02 Nov 2012)

Log Message

[EFL][WK2] Change the scope of locking in WorkQueueEfl.cpp.
https://bugs.webkit.org/show_bug.cgi?id=98978

Patch by Byungwoo Lee <bw80....@samsung.com> on 2012-11-02
Reviewed by Kenneth Rohde Christiansen.

Release the m_workItemQueueLock and m_timerWorkItemsLock mutexes
immediately after the protected resource is no longer modified to
prevent a possible source of a deadlock.

And additional mutex locker for the m_writeToPipeDescriptor is added
to ensure thread-safety of the sendMessageToThread() function.

* Platform/WorkQueue.h:
(WorkQueue):
* Platform/efl/WorkQueueEfl.cpp:
(WorkQueue::insertTimerWorkItem):
(WorkQueue::performTimerWork):
(WorkQueue::sendMessageToThread):
(WorkQueue::dispatch):
(WorkQueue::dispatchAfterDelay):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (133306 => 133307)


--- trunk/Source/WebKit2/ChangeLog	2012-11-02 16:16:45 UTC (rev 133306)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-02 16:30:24 UTC (rev 133307)
@@ -1,3 +1,26 @@
+2012-11-02  Byungwoo Lee  <bw80....@samsung.com>
+
+        [EFL][WK2] Change the scope of locking in WorkQueueEfl.cpp.
+        https://bugs.webkit.org/show_bug.cgi?id=98978
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Release the m_workItemQueueLock and m_timerWorkItemsLock mutexes
+        immediately after the protected resource is no longer modified to
+        prevent a possible source of a deadlock.
+
+        And additional mutex locker for the m_writeToPipeDescriptor is added
+        to ensure thread-safety of the sendMessageToThread() function.
+
+        * Platform/WorkQueue.h:
+        (WorkQueue):
+        * Platform/efl/WorkQueueEfl.cpp:
+        (WorkQueue::insertTimerWorkItem):
+        (WorkQueue::performTimerWork):
+        (WorkQueue::sendMessageToThread):
+        (WorkQueue::dispatch):
+        (WorkQueue::dispatchAfterDelay):
+
 2012-11-02  Mikhail Pozdnyakov  <mikhail.pozdnya...@intel.com>
 
         [EFL][WK2] Add API unit tests for Ewk_Object

Modified: trunk/Source/WebKit2/Platform/WorkQueue.h (133306 => 133307)


--- trunk/Source/WebKit2/Platform/WorkQueue.h	2012-11-02 16:16:45 UTC (rev 133306)
+++ trunk/Source/WebKit2/Platform/WorkQueue.h	2012-11-02 16:30:24 UTC (rev 133307)
@@ -206,6 +206,8 @@
     int m_maxFileDescriptor;
     int m_readFromPipeDescriptor;
     int m_writeToPipeDescriptor;
+    Mutex m_writeToPipeDescriptorLock;
+
     bool m_threadLoop;
 
     Vector<Function<void()> > m_workItemQueue;

Modified: trunk/Source/WebKit2/Platform/efl/WorkQueueEfl.cpp (133306 => 133307)


--- trunk/Source/WebKit2/Platform/efl/WorkQueueEfl.cpp	2012-11-02 16:16:45 UTC (rev 133306)
+++ trunk/Source/WebKit2/Platform/efl/WorkQueueEfl.cpp	2012-11-02 16:30:24 UTC (rev 133307)
@@ -127,6 +127,7 @@
 
     size_t position = 0;
 
+    MutexLocker locker(m_timerWorkItemsLock);
     // m_timerWorkItems should be ordered by expire time.
     for (; position < m_timerWorkItems.size(); ++position)
         if (item->expireTime() < m_timerWorkItems[position]->expireTime())
@@ -153,7 +154,6 @@
 
     for (size_t i = 0; i < timerWorkItems.size(); ++i) {
         if (!timerWorkItems[i]->expired(current)) {
-            MutexLocker locker(m_timerWorkItemsLock);
             // If a timer work item does not expired, keep it to the m_timerWorkItems.
             // m_timerWorkItems should be ordered by expire time.
             insertTimerWorkItem(timerWorkItems[i].release());
@@ -167,6 +167,7 @@
 
 void WorkQueue::sendMessageToThread(const char* message)
 {
+    MutexLocker locker(m_writeToPipeDescriptorLock);
     if (write(m_writeToPipeDescriptor, message, threadMessageSize) == -1)
         LOG_ERROR("Failed to wake up WorkQueue Thread");
 }
@@ -209,8 +210,11 @@
 
 void WorkQueue::dispatch(const Function<void()>& function)
 {
-    MutexLocker locker(m_workItemQueueLock);
-    m_workItemQueue.append(function);
+    {
+        MutexLocker locker(m_workItemQueueLock);
+        m_workItemQueue.append(function);
+    }
+
     sendMessageToThread(wakupThreadMessage);
 }
 
@@ -219,7 +223,6 @@
     if (delay < 0)
         return;
 
-    MutexLocker locker(m_timerWorkItemsLock);
     OwnPtr<TimerWorkItem> timerWorkItem = TimerWorkItem::create(function, currentTime() + delay);
     if (!timerWorkItem)
         return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to