Title: [205125] trunk/Source/WebKit2
Revision
205125
Author
[email protected]
Date
2016-08-29 10:49:13 -0700 (Mon, 29 Aug 2016)

Log Message

Remove sync message sending from secondary threads
https://bugs.webkit.org/show_bug.cgi?id=161277

Reviewed by Sam Weinig.

This codepath hasn't been used for some time, and removing it will make it easier to make IPC::Connection backed by libxpc.

* Platform/IPC/Connection.cpp:
(IPC::Connection::sendSyncMessage):
(IPC::Connection::processIncomingSyncReply):
(IPC::Connection::connectionDidClose):
(IPC::Connection::sendSyncMessageFromSecondaryThread): Deleted.
* Platform/IPC/Connection.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (205124 => 205125)


--- trunk/Source/WebKit2/ChangeLog	2016-08-29 17:26:47 UTC (rev 205124)
+++ trunk/Source/WebKit2/ChangeLog	2016-08-29 17:49:13 UTC (rev 205125)
@@ -1,3 +1,19 @@
+2016-08-26  Anders Carlsson  <[email protected]>
+
+        Remove sync message sending from secondary threads
+        https://bugs.webkit.org/show_bug.cgi?id=161277
+
+        Reviewed by Sam Weinig.
+
+        This codepath hasn't been used for some time, and removing it will make it easier to make IPC::Connection backed by libxpc.
+
+        * Platform/IPC/Connection.cpp:
+        (IPC::Connection::sendSyncMessage):
+        (IPC::Connection::processIncomingSyncReply):
+        (IPC::Connection::connectionDidClose):
+        (IPC::Connection::sendSyncMessageFromSecondaryThread): Deleted.
+        * Platform/IPC/Connection.h:
+
 2016-08-16  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Accelerated compositing does not work in Wayland

Modified: trunk/Source/WebKit2/Platform/IPC/Connection.cpp (205124 => 205125)


--- trunk/Source/WebKit2/Platform/IPC/Connection.cpp	2016-08-29 17:26:47 UTC (rev 205124)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.cpp	2016-08-29 17:49:13 UTC (rev 205125)
@@ -98,15 +98,6 @@
     Vector<ConnectionAndIncomingMessage> m_messagesToDispatchWhileWaitingForSyncReply;
 };
 
-class Connection::SecondaryThreadPendingSyncReply {
-public:
-    // The reply decoder, will be null if there was an error processing the sync message on the other side.
-    std::unique_ptr<Decoder> replyDecoder;
-
-    BinarySemaphore semaphore;
-};
-
-
 Connection::SyncMessageState& Connection::SyncMessageState::singleton()
 {
     static std::once_flag onceFlag;
@@ -449,13 +440,8 @@
 
 std::unique_ptr<Decoder> Connection::sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<Encoder> encoder, std::chrono::milliseconds timeout, OptionSet<SendSyncOption> sendSyncOptions)
 {
-    if (!RunLoop::isMain()) {
-        // No flags are supported for synchronous messages sent from secondary threads.
-        ASSERT(sendSyncOptions.isEmpty());
+    ASSERT(RunLoop::isMain());
 
-        return sendSyncMessageFromSecondaryThread(syncRequestID, WTFMove(encoder), timeout);
-    }
-
     if (!isValid()) {
         didFailToSendSyncMessage();
         return nullptr;
@@ -497,40 +483,6 @@
     return reply;
 }
 
-std::unique_ptr<Decoder> Connection::sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<Encoder> encoder, std::chrono::milliseconds timeout)
-{
-    ASSERT(!RunLoop::isMain());
-
-    if (!isValid())
-        return nullptr;
-
-    SecondaryThreadPendingSyncReply pendingReply;
-
-    // Push the pending sync reply information on our stack.
-    {
-        LockHolder locker(m_syncReplyStateMutex);
-        if (!m_shouldWaitForSyncReplies)
-            return nullptr;
-
-        ASSERT(!m_secondaryThreadPendingSyncReplyMap.contains(syncRequestID));
-        m_secondaryThreadPendingSyncReplyMap.add(syncRequestID, &pendingReply);
-    }
-
-    sendMessage(WTFMove(encoder), { });
-
-    timeout = timeoutRespectingIgnoreTimeoutsForTesting(timeout);
-    pendingReply.semaphore.wait(currentTime() + (timeout.count() / 1000.0));
-
-    // Finally, pop the pending sync reply information.
-    {
-        LockHolder locker(m_syncReplyStateMutex);
-        ASSERT(m_secondaryThreadPendingSyncReplyMap.contains(syncRequestID));
-        m_secondaryThreadPendingSyncReplyMap.remove(syncRequestID);
-    }
-
-    return WTFMove(pendingReply.replyDecoder);
-}
-
 std::unique_ptr<Decoder> Connection::waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, OptionSet<SendSyncOption> sendSyncOptions)
 {
     timeout = timeoutRespectingIgnoreTimeoutsForTesting(timeout);
@@ -605,15 +557,6 @@
         return;
     }
 
-    // If it's not a reply to any primary thread message, check if it is a reply to a secondary thread one.
-    SecondaryThreadPendingSyncReplyMap::iterator secondaryThreadReplyMapItem = m_secondaryThreadPendingSyncReplyMap.find(decoder->destinationID());
-    if (secondaryThreadReplyMapItem != m_secondaryThreadPendingSyncReplyMap.end()) {
-        SecondaryThreadPendingSyncReply* reply = secondaryThreadReplyMapItem->value;
-        ASSERT(!reply->replyDecoder);
-        reply->replyDecoder = WTFMove(decoder);
-        reply->semaphore.signal();
-    }
-
     // If we get here, it means we got a reply for a message that wasn't in the sync request stack or map.
     // This can happen if the send timed out, so it's fine to ignore.
 }
@@ -745,9 +688,6 @@
 
         if (!m_pendingSyncReplies.isEmpty())
             SyncMessageState::singleton().wakeUpClientRunLoop();
-
-        for (SecondaryThreadPendingSyncReplyMap::iterator iter = m_secondaryThreadPendingSyncReplyMap.begin(); iter != m_secondaryThreadPendingSyncReplyMap.end(); ++iter)
-            iter->value->semaphore.signal();
     }
 
     {

Modified: trunk/Source/WebKit2/Platform/IPC/Connection.h (205124 => 205125)


--- trunk/Source/WebKit2/Platform/IPC/Connection.h	2016-08-29 17:26:47 UTC (rev 205124)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.h	2016-08-29 17:49:13 UTC (rev 205125)
@@ -172,7 +172,6 @@
     std::unique_ptr<Encoder> createSyncMessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID);
     bool sendMessage(std::unique_ptr<Encoder>, OptionSet<SendOption> sendOptions);
     std::unique_ptr<Decoder> sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<Encoder>, std::chrono::milliseconds timeout, OptionSet<SendSyncOption> sendSyncOptions);
-    std::unique_ptr<Decoder> sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<Encoder>, std::chrono::milliseconds timeout);
     bool sendSyncReply(std::unique_ptr<Encoder>);
 
     void wakeUpRunLoop();
@@ -306,10 +305,6 @@
     bool m_shouldWaitForSyncReplies;
     Vector<PendingSyncReply> m_pendingSyncReplies;
 
-    class SecondaryThreadPendingSyncReply;
-    typedef HashMap<uint64_t, SecondaryThreadPendingSyncReply*> SecondaryThreadPendingSyncReplyMap;
-    SecondaryThreadPendingSyncReplyMap m_secondaryThreadPendingSyncReplyMap;
-
     Lock m_incomingSyncMessageCallbackMutex;
     HashMap<uint64_t, std::function<void ()>> m_incomingSyncMessageCallbacks;
     RefPtr<WorkQueue> m_incomingSyncMessageCallbackQueue;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to