Title: [211859] releases/WebKitGTK/webkit-2.14/Source/WebKit2
Revision
211859
Author
[email protected]
Date
2017-02-08 03:05:21 -0800 (Wed, 08 Feb 2017)

Log Message

Merge r211734 - [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.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog (211858 => 211859)


--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog	2017-02-08 11:05:13 UTC (rev 211858)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog	2017-02-08 11:05:21 UTC (rev 211859)
@@ -1,3 +1,20 @@
+2017-02-06  Carlos Garcia Campos  <[email protected]>
+
+        [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.
+
 2017-01-04  Carlos Garcia Campos  <[email protected]>
 
         [SOUP] Network process crash in WebKit::CustomProtocolManagerImpl::didFailWithError

Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp (211858 => 211859)


--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp	2017-02-08 11:05:13 UTC (rev 211858)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp	2017-02-08 11:05:21 UTC (rev 211859)
@@ -20,8 +20,7 @@
 #include "config.h"
 #include "WebKitSoupRequestInputStream.h"
 
-#include <wtf/Lock.h>
-#include <wtf/Threading.h>
+#include <wtf/MainThread.h>
 #include <wtf/glib/GRefPtr.h>
 #include <wtf/glib/GUniquePtr.h>
 
@@ -45,7 +44,6 @@
 
     GUniquePtr<GError> error;
 
-    Lock readLock;
     std::unique_ptr<AsyncReadData> pendingAsyncRead;
 };
 
@@ -85,11 +83,10 @@
 
 static void webkitSoupRequestInputStreamReadAsync(GInputStream* inputStream, void* buffer, gsize count, int /*priority*/, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
 {
+    ASSERT(isMainThread());
     WebKitSoupRequestInputStream* stream = WEBKIT_SOUP_REQUEST_INPUT_STREAM(inputStream);
     GRefPtr<GTask> task = adoptGRef(g_task_new(stream, cancellable, callback, userData));
 
-    LockHolder locker(stream->priv->readLock);
-
     if (!webkitSoupRequestInputStreamHasDataToRead(stream) && !webkitSoupRequestInputStreamIsWaitingForData(stream)) {
         g_task_return_int(task.get(), 0);
         return;
@@ -149,11 +146,11 @@
 
 void webkitSoupRequestInputStreamAddData(WebKitSoupRequestInputStream* stream, const void* data, size_t dataLength)
 {
+    ASSERT(isMainThread());
+
     if (webkitSoupRequestInputStreamFinished(stream))
         return;
 
-    LockHolder locker(stream->priv->readLock);
-
     if (dataLength) {
         // Truncate the dataLength to the contentLength if it's known.
         if (stream->priv->contentLength && stream->priv->bytesReceived + dataLength > stream->priv->contentLength)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to