Title: [88588] trunk/Source/WebKit2
Revision
88588
Author
[email protected]
Date
2011-06-10 19:04:32 -0700 (Fri, 10 Jun 2011)

Log Message

2011-06-10  Anders Carlsson  <[email protected]>

        Reviewed by Sam Weinig.

        REGRESSION (WebKit2): window.showModalDialog() broken
        https://bugs.webkit.org/show_bug.cgi?id=62496
        <rdar://problem/9581492>

        If dispatching a message ends up creating a nested run loop, some incoming messages can end up not being
        delivered until we exit from the run loop.

        Fix this by using a Deque instead of a Vector for incoming messages, and get one message at a time and then
        dispatch it. That prevents us from having any lingering messages lying around in stack allocated space.

        * Platform/CoreIPC/Connection.cpp:
        (CoreIPC::Connection::waitForMessage):
        (CoreIPC::Connection::dispatchMessages):
        * Platform/CoreIPC/Connection.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (88587 => 88588)


--- trunk/Source/WebKit2/ChangeLog	2011-06-11 02:03:00 UTC (rev 88587)
+++ trunk/Source/WebKit2/ChangeLog	2011-06-11 02:04:32 UTC (rev 88588)
@@ -1,3 +1,22 @@
+2011-06-10  Anders Carlsson  <[email protected]>
+
+        Reviewed by Sam Weinig.
+
+        REGRESSION (WebKit2): window.showModalDialog() broken
+        https://bugs.webkit.org/show_bug.cgi?id=62496
+        <rdar://problem/9581492>
+
+        If dispatching a message ends up creating a nested run loop, some incoming messages can end up not being
+        delivered until we exit from the run loop.
+
+        Fix this by using a Deque instead of a Vector for incoming messages, and get one message at a time and then
+        dispatch it. That prevents us from having any lingering messages lying around in stack allocated space.
+
+        * Platform/CoreIPC/Connection.cpp:
+        (CoreIPC::Connection::waitForMessage):
+        (CoreIPC::Connection::dispatchMessages):
+        * Platform/CoreIPC/Connection.h:
+
 2011-06-10  Sam Weinig  <[email protected]>
 
         Reviewed by Anders Carlsson.

Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp (88587 => 88588)


--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp	2011-06-11 02:03:00 UTC (rev 88587)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp	2011-06-11 02:04:32 UTC (rev 88588)
@@ -326,14 +326,13 @@
     {
         MutexLocker locker(m_incomingMessagesLock);
 
-        for (size_t i = 0; i < m_incomingMessages.size(); ++i) {
-            IncomingMessage& message = m_incomingMessages[i];
+        for (Deque<IncomingMessage>::iterator it = m_incomingMessages.begin(), end = m_incomingMessages.end(); it != end; ++it) {
+            IncomingMessage& message = *it;
 
             if (message.messageID() == messageID && message.arguments()->destinationID() == destinationID) {
                 OwnPtr<ArgumentDecoder> arguments = message.releaseArguments();
 
-                // Erase the incoming message.
-                m_incomingMessages.remove(i);
+                m_incomingMessages.remove(it);
                 return arguments.release();
             }
         }
@@ -689,15 +688,19 @@
 
 void Connection::dispatchMessages()
 {
-    Vector<IncomingMessage> incomingMessages;
-    
-    {
-        MutexLocker locker(m_incomingMessagesLock);
-        m_incomingMessages.swap(incomingMessages);
+    while (true) {
+        IncomingMessage incomingMessage;
+
+        {
+            MutexLocker locker(m_incomingMessagesLock);
+            if (m_incomingMessages.isEmpty())
+                break;
+
+            incomingMessage = m_incomingMessages.takeFirst();
+        }
+
+        dispatchMessage(incomingMessage);
     }
-
-    for (size_t i = 0; i < incomingMessages.size(); ++i)
-        dispatchMessage(incomingMessages[i]);
 }
 
 } // namespace CoreIPC

Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.h (88587 => 88588)


--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2011-06-11 02:03:00 UTC (rev 88587)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2011-06-11 02:04:32 UTC (rev 88588)
@@ -257,7 +257,7 @@
 
     // Incoming messages.
     Mutex m_incomingMessagesLock;
-    Vector<IncomingMessage> m_incomingMessages;
+    Deque<IncomingMessage> m_incomingMessages;
 
     // Outgoing messages.
     Mutex m_outgoingMessagesLock;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to