Bug 132144 - Don't use DispatchMessageEvenWhenWaitingForSyncReply for messages from NetworkProcess
Summary: Don't use DispatchMessageEvenWhenWaitingForSyncReply for messages from Networ...
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alexey Proskuryakov
Depends on:
Reported: 2014-04-24 14:11 PDT by Alexey Proskuryakov
Modified: 2014-04-27 18:56 PDT (History)
4 users (show)

See Also:

proposed patch (4.63 KB, patch)
2014-04-24 14:13 PDT, Alexey Proskuryakov
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.