Don't use DispatchMessageEvenWhenWaitingForSyncReply for messages from NetworkProcess
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Apr 2014 01:55:35 +0000 (01:55 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Apr 2014 01:55:35 +0000 (01:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132144

Reviewed by Darin Adler.

* NetworkProcess/AsynchronousNetworkLoaderClient.cpp:
(WebKit::AsynchronousNetworkLoaderClient::willSendRequest):
(WebKit::AsynchronousNetworkLoaderClient::canAuthenticateAgainstProtectionSpace):
Dont use the IPC::DispatchMessageEvenWhenWaitingForSyncReply flag. It's not needed,
almost never works in NetworkProcess, but may cause trouble if it did.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::NetworkConnectionToWebProcess): Removed
setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage()
function call, because there are no more any messages in NetworkProcess it could affect.

* Platform/IPC/Connection.cpp: (IPC::Connection::dispatchMessage): Added a FIXME
for an unrelated bug Anders and myself noticed while looking into this.

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

Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/AsynchronousNetworkLoaderClient.cpp
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit2/Platform/IPC/Connection.cpp

index a97a1d9..e36b0cc 100644 (file)
@@ -1,3 +1,24 @@
+2014-04-27  Alexey Proskuryakov  <ap@apple.com>
+
+        Don't use DispatchMessageEvenWhenWaitingForSyncReply for messages from NetworkProcess
+        https://bugs.webkit.org/show_bug.cgi?id=132144
+
+        Reviewed by Darin Adler.
+
+        * NetworkProcess/AsynchronousNetworkLoaderClient.cpp:
+        (WebKit::AsynchronousNetworkLoaderClient::willSendRequest):
+        (WebKit::AsynchronousNetworkLoaderClient::canAuthenticateAgainstProtectionSpace):
+        Dont use the IPC::DispatchMessageEvenWhenWaitingForSyncReply flag. It's not needed,
+        almost never works in NetworkProcess, but may cause trouble if it did.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::NetworkConnectionToWebProcess): Removed
+        setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage()
+        function call, because there are no more any messages in NetworkProcess it could affect.
+
+        * Platform/IPC/Connection.cpp: (IPC::Connection::dispatchMessage): Added a FIXME
+        for an unrelated bug Anders and myself noticed while looking into this.
+
 2014-04-27  Dan Bernstein  <mitz@apple.com>
 
         [Cocoa] -[WKWebProcessPlugInController parameters] returns nil if no parameters have been set yet
index 04e68d2..3f3a3ce 100644 (file)
@@ -50,17 +50,13 @@ AsynchronousNetworkLoaderClient::AsynchronousNetworkLoaderClient()
 
 void AsynchronousNetworkLoaderClient::willSendRequest(NetworkResourceLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
 {
-    // This message is DispatchMessageEvenWhenWaitingForSyncReply to avoid a situation where the NetworkProcess is deadlocked
-    // waiting for 6 connections to complete while the WebProcess is waiting for a 7th (Synchronous XHR) to complete.
-    loader->sendAbortingOnFailure(Messages::WebResourceLoader::WillSendRequest(request, redirectResponse), IPC::DispatchMessageEvenWhenWaitingForSyncReply);
+    loader->sendAbortingOnFailure(Messages::WebResourceLoader::WillSendRequest(request, redirectResponse));
 }
 
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
 void AsynchronousNetworkLoaderClient::canAuthenticateAgainstProtectionSpace(NetworkResourceLoader* loader, const ProtectionSpace& protectionSpace)
 {
-    // This message is DispatchMessageEvenWhenWaitingForSyncReply to avoid a situation where the NetworkProcess is deadlocked
-    // waiting for 6 connections to complete while the WebProcess is waiting for a 7th (Synchronous XHR) to complete.
-    loader->sendAbortingOnFailure(Messages::WebResourceLoader::CanAuthenticateAgainstProtectionSpace(protectionSpace), IPC::DispatchMessageEvenWhenWaitingForSyncReply);
+    loader->sendAbortingOnFailure(Messages::WebResourceLoader::CanAuthenticateAgainstProtectionSpace(protectionSpace));
 }
 #endif
 
index e2f089e..36140a3 100644 (file)
@@ -58,7 +58,6 @@ NetworkConnectionToWebProcess::NetworkConnectionToWebProcess(IPC::Connection::Id
     : m_serialLoadingEnabled(false)
 {
     m_connection = IPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main());
-    m_connection->setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(true);
     m_connection->open();
 }
 
index 4352a2c..321c120 100644 (file)
@@ -794,6 +794,8 @@ void Connection::dispatchMessage(std::unique_ptr<MessageDecoder> message)
     m_didReceiveInvalidMessage |= message->isInvalid();
     m_inDispatchMessageCount--;
 
+    // FIXME: For Delayed synchronous messages, we should not decrement the counter until we send a response.
+    // Otherwise, we would deadlock if processing the message results in a sync message back after we exit this function.
     if (message->shouldDispatchMessageWhenWaitingForSyncReply())
         m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount--;