Bug 132144

Summary: Don't use DispatchMessageEvenWhenWaitingForSyncReply for messages from NetworkProcess
Product: WebKit Reporter: Alexey Proskuryakov <ap>
Component: WebKit2Assignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, beidson, commit-queue, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
proposed patch none

Description Alexey Proskuryakov 2014-04-24 14:11:06 PDT
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);
}


There are several confusing things here:

1. If we send messages with IPC::DispatchMessageEvenWhenWaitingForSyncReply from NetworkProcess, they can be handled during sync XHR, causing undesirable reentrancy. That's dangerous.

2. But IPC::DispatchMessageEvenWhenWaitingForSyncReply doesn't really work in NetworkProcess, because the connection uses setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(true), so the flag is usually ignored. When it's not ignored, see the above.

3. The comment claims that we need this because otherwise we would have a deadlock. It's not accurate - we would happily load sync requests even if there are 6 async ones stuck. We disable connection limits for sync requests, even when pipelining is not in use.

This is probably difficult to reproduce in practice.
Comment 1 Alexey Proskuryakov 2014-04-24 14:13:49 PDT
Created attachment 230105 [details]
proposed patch
Comment 2 WebKit Commit Bot 2014-04-27 18:56:03 PDT
Comment on attachment 230105 [details]
proposed patch

Clearing flags on attachment: 230105

Committed r167866: <http://trac.webkit.org/changeset/167866>
Comment 3 WebKit Commit Bot 2014-04-27 18:56:06 PDT
All reviewed patches have been landed.  Closing bug.