Unreviewed, rolling out r247932.
authortsavell@apple.com <tsavell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jul 2019 15:40:01 +0000 (15:40 +0000)
committertsavell@apple.com <tsavell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jul 2019 15:40:01 +0000 (15:40 +0000)
Broke 8 API tests across all platforms.

Reverted changeset:

"Fix non-thread safe use of WeakPtr under
sendSecItemRequest()"
https://bugs.webkit.org/show_bug.cgi?id=200249
https://trac.webkit.org/changeset/247932

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

Source/WebKit/ChangeLog
Source/WebKit/Shared/mac/SecItemShim.cpp
Source/WebKit/UIProcess/mac/SecItemShimProxy.cpp
Source/WebKit/UIProcess/mac/SecItemShimProxy.h
Source/WebKit/UIProcess/mac/SecItemShimProxy.messages.in

index 10abba7..6ffbc39 100644 (file)
@@ -1,3 +1,16 @@
+2019-07-30  Truitt Savell  <tsavell@apple.com>
+
+        Unreviewed, rolling out r247932.
+
+        Broke 8 API tests across all platforms.
+
+        Reverted changeset:
+
+        "Fix non-thread safe use of WeakPtr under
+        sendSecItemRequest()"
+        https://bugs.webkit.org/show_bug.cgi?id=200249
+        https://trac.webkit.org/changeset/247932
+
 2019-07-29  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         YouTube search field shows RTL text outside its border on iPadOS
index 0244f4f..147054f 100644 (file)
@@ -64,22 +64,32 @@ static WeakPtr<NetworkProcess>& globalNetworkProcess()
     return networkProcess.get();
 }
 
+static WorkQueue& workQueue()
+{
+    static WorkQueue* workQueue;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        workQueue = &WorkQueue::create("com.apple.WebKit.SecItemShim").leakRef();
+
+    });
+
+    return *workQueue;
+}
+
 static Optional<SecItemResponseData> sendSecItemRequest(SecItemRequestData::Type requestType, CFDictionaryRef query, CFDictionaryRef attributesToMatch = 0)
 {
+    if (!globalNetworkProcess())
+        return WTF::nullopt;
+
     Optional<SecItemResponseData> response;
 
     BinarySemaphore semaphore;
-    RunLoop::main().dispatch([&] {
-        if (!globalNetworkProcess()) {
-            semaphore.signal();
-            return;
-        }
-        globalNetworkProcess()->parentProcessConnection()->sendWithAsyncReply(Messages::SecItemShimProxy::SecItemRequest(SecItemRequestData(requestType, query, attributesToMatch)), [&](auto reply) {
-            if (reply)
-                response = WTFMove(*reply);
-
-            semaphore.signal();
-        });
+
+    globalNetworkProcess()->parentProcessConnection()->sendWithReply(Messages::SecItemShimProxy::SecItemRequest(SecItemRequestData(requestType, query, attributesToMatch)), 0, workQueue(), [&response, &semaphore](auto reply) {
+        if (reply)
+            response = WTFMove(std::get<0>(*reply));
+
+        semaphore.signal();
     });
 
     semaphore.wait();
index 1a39ba4..d12bff6 100644 (file)
@@ -56,7 +56,11 @@ void SecItemShimProxy::initializeConnection(IPC::Connection& connection)
     connection.addWorkQueueMessageReceiver(Messages::SecItemShimProxy::messageReceiverName(), m_queue.get(), this);
 }
 
-void SecItemShimProxy::secItemRequest(const SecItemRequestData& request, CompletionHandler<void(Optional<SecItemResponseData>&&)>&& response)
+void SecItemShimProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&)
+{
+}
+
+void SecItemShimProxy::secItemRequest(const SecItemRequestData& request, CompletionHandler<void(SecItemResponseData&&)>&& response)
 {
     switch (request.type()) {
     case SecItemRequestData::Invalid:
index fc09f67..e72a102 100644 (file)
@@ -46,8 +46,9 @@ private:
 
     // IPC::Connection::WorkQueueMessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
+    void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
 
-    void secItemRequest(const SecItemRequestData&, CompletionHandler<void(Optional<SecItemResponseData>&&)>&&);
+    void secItemRequest(const SecItemRequestData&, CompletionHandler<void(SecItemResponseData&&)>&&);
 
     Ref<WorkQueue> m_queue;
 };
index 458bc43..3240d8b 100644 (file)
@@ -23,7 +23,7 @@
 messages -> SecItemShimProxy {
 
 #if ENABLE(SEC_ITEM_SHIM)
-    SecItemRequest(WebKit::SecItemRequestData request) -> (Optional<WebKit::SecItemResponseData> response) Async
+    SecItemRequest(WebKit::SecItemRequestData request) -> (WebKit::SecItemResponseData response) Synchronous
 #endif
 
 }