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

Log Message

Merge r211773 - [Soup] Long resources loaded by custom protocols sometimes never finish loading
https://bugs.webkit.org/show_bug.cgi?id=167890

Reviewed by Michael Catanzaro.

It's another bug that has appeared in WebKitSoupRequestInputStream after moving the custom protocols handling to
the main thread. The problem is that webkitSoupRequestInputStreamPendingReadAsyncComplete invalidates
pendingAsyncRead after calling webkitSoupRequestInputStreamReadAsyncResultComplete, but in some cases
webkitSoupRequestInputStreamReadAsyncResultComplete completes the task in the same run loop iteration. In that
case webkitSoupRequestInputStreamReadAsync is called again creating a new AsyncReadData that is destroyed right
after webkitSoupRequestInputStreamReadAsyncResultComplete returns.

* WebProcess/soup/WebKitSoupRequestInputStream.cpp:
(AsyncReadData::AsyncReadData): Use an rvalue reference for the task.
(webkitSoupRequestInputStreamPendingReadAsyncComplete): Use WTFMove to ensure pendingAsyncRead is cleared before
webkitSoupRequestInputStreamReadAsyncResultComplete is called, and continue processing pending requests if there
are new ones after webkitSoupRequestInputStreamReadAsyncResultComplete.
(webkitSoupRequestInputStreamReadAsync): Use WTFMove to transfer the task to AsyncReadData.
(webkitSoupRequestInputStreamDidFailWithError): Use WTFMove to ensure pendingAsyncRead is cleared.

Modified Paths

Diff

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


--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog	2017-02-08 11:05:21 UTC (rev 211859)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog	2017-02-08 11:05:26 UTC (rev 211860)
@@ -1,5 +1,27 @@
 2017-02-06  Carlos Garcia Campos  <[email protected]>
 
+        [Soup] Long resources loaded by custom protocols sometimes never finish loading
+        https://bugs.webkit.org/show_bug.cgi?id=167890
+
+        Reviewed by Michael Catanzaro.
+
+        It's another bug that has appeared in WebKitSoupRequestInputStream after moving the custom protocols handling to
+        the main thread. The problem is that webkitSoupRequestInputStreamPendingReadAsyncComplete invalidates
+        pendingAsyncRead after calling webkitSoupRequestInputStreamReadAsyncResultComplete, but in some cases
+        webkitSoupRequestInputStreamReadAsyncResultComplete completes the task in the same run loop iteration. In that
+        case webkitSoupRequestInputStreamReadAsync is called again creating a new AsyncReadData that is destroyed right
+        after webkitSoupRequestInputStreamReadAsyncResultComplete returns.
+
+        * WebProcess/soup/WebKitSoupRequestInputStream.cpp:
+        (AsyncReadData::AsyncReadData): Use an rvalue reference for the task.
+        (webkitSoupRequestInputStreamPendingReadAsyncComplete): Use WTFMove to ensure pendingAsyncRead is cleared before
+        webkitSoupRequestInputStreamReadAsyncResultComplete is called, and continue processing pending requests if there
+        are new ones after webkitSoupRequestInputStreamReadAsyncResultComplete.
+        (webkitSoupRequestInputStreamReadAsync): Use WTFMove to transfer the task to AsyncReadData.
+        (webkitSoupRequestInputStreamDidFailWithError): Use WTFMove to ensure pendingAsyncRead is cleared.
+
+2017-02-06  Carlos Garcia Campos  <[email protected]>
+
         [Soup] Deadlock in NetworkProcess
         https://bugs.webkit.org/show_bug.cgi?id=167876
 

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


--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp	2017-02-08 11:05:21 UTC (rev 211859)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp	2017-02-08 11:05:26 UTC (rev 211860)
@@ -25,8 +25,8 @@
 #include <wtf/glib/GUniquePtr.h>
 
 struct AsyncReadData {
-    AsyncReadData(GTask* task, void* buffer, gsize count)
-        : task(task)
+    AsyncReadData(GRefPtr<GTask>&& task, void* buffer, gsize count)
+        : task(WTFMove(task))
         , buffer(buffer)
         , count(count)
     {
@@ -63,12 +63,10 @@
 
 static void webkitSoupRequestInputStreamPendingReadAsyncComplete(WebKitSoupRequestInputStream* stream)
 {
-    if (!stream->priv->pendingAsyncRead)
-        return;
-
-    AsyncReadData* data = ""
-    webkitSoupRequestInputStreamReadAsyncResultComplete(data->task.get(), data->buffer, data->count);
-    stream->priv->pendingAsyncRead = nullptr;
+    while (stream->priv->pendingAsyncRead) {
+        auto data = ""
+        webkitSoupRequestInputStreamReadAsyncResultComplete(data->task.get(), data->buffer, data->count);
+    }
 }
 
 static bool webkitSoupRequestInputStreamHasDataToRead(WebKitSoupRequestInputStream* stream)
@@ -102,7 +100,7 @@
         return;
     }
 
-    stream->priv->pendingAsyncRead = std::make_unique<AsyncReadData>(task.get(), buffer, count);
+    stream->priv->pendingAsyncRead = std::make_unique<AsyncReadData>(WTFMove(task), buffer, count);
 }
 
 static gssize webkitSoupRequestInputStreamReadFinish(GInputStream* inputStream, GAsyncResult* result, GError** error)
@@ -171,10 +169,9 @@
 void webkitSoupRequestInputStreamDidFailWithError(WebKitSoupRequestInputStream* stream, const WebCore::ResourceError& resourceError)
 {
     GUniquePtr<GError> error(g_error_new(g_quark_from_string(resourceError.domain().utf8().data()), resourceError.errorCode(), "%s", resourceError.localizedDescription().utf8().data()));
-    if (stream->priv->pendingAsyncRead) {
-        AsyncReadData* data = ""
+    if (auto data = ""
         g_task_return_error(data->task.get(), error.release());
-    } else {
+    else {
         stream->priv->contentLength = stream->priv->bytesReceived;
         stream->priv->error = WTFMove(error);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to