Ignore:
Timestamp:
Feb 6, 2017, 10:00:52 AM (9 years ago)
Author:
Carlos Garcia Campos
Message:

[Soup] Deadlock in NetworkProcess
https://bugs.webkit.org/show_bug.cgi?id=167876

Reviewed by Michael Catanzaro.

WebKitSoupRequestInputStream uses a read lock. What is happening is that webkitSoupRequestInputStreamAddData
takes the lock, and it calls webkitSoupRequestInputStreamPendingReadAsyncComplete with the lock help. That
causes webkitSoupRequestInputStreamReadAsync to be called again to read the next chunk, but in the same run loop
operation. We don't really need the read lock because both webkitSoupRequestInputStreamAddData and
webkitSoupRequestInputStreamReadAsync shoudl always be called from the main thread.

  • WebProcess/soup/WebKitSoupRequestInputStream.cpp:

(webkitSoupRequestInputStreamReadAsync): Remove the read lock and assert if called from a secondary thread.
(webkitSoupRequestInputStreamAddData): Ditto.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp

    r194496 r211734  
    2121#include "WebKitSoupRequestInputStream.h"
    2222
    23 #include <wtf/Lock.h>
    24 #include <wtf/Threading.h>
     23#include <wtf/MainThread.h>
    2524#include <wtf/glib/GRefPtr.h>
    2625#include <wtf/glib/GUniquePtr.h>
     
    4645    GUniquePtr<GError> error;
    4746
    48     Lock readLock;
    4947    std::unique_ptr<AsyncReadData> pendingAsyncRead;
    5048};
     
    8684static void webkitSoupRequestInputStreamReadAsync(GInputStream* inputStream, void* buffer, gsize count, int /*priority*/, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
    8785{
     86    ASSERT(isMainThread());
    8887    WebKitSoupRequestInputStream* stream = WEBKIT_SOUP_REQUEST_INPUT_STREAM(inputStream);
    8988    GRefPtr<GTask> task = adoptGRef(g_task_new(stream, cancellable, callback, userData));
    90 
    91     LockHolder locker(stream->priv->readLock);
    9289
    9390    if (!webkitSoupRequestInputStreamHasDataToRead(stream) && !webkitSoupRequestInputStreamIsWaitingForData(stream)) {
     
    150147void webkitSoupRequestInputStreamAddData(WebKitSoupRequestInputStream* stream, const void* data, size_t dataLength)
    151148{
     149    ASSERT(isMainThread());
     150
    152151    if (webkitSoupRequestInputStreamFinished(stream))
    153152        return;
    154 
    155     LockHolder locker(stream->priv->readLock);
    156153
    157154    if (dataLength) {
Note: See TracChangeset for help on using the changeset viewer.