http/tests/xmlhttprequest/workers/methods.html sometimes times out with disk cache...
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jan 2015 17:08:16 +0000 (17:08 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jan 2015 17:08:16 +0000 (17:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140976

Reviewed by Chris Dumez.

Running

    run-webkit-tests --release -2 http/tests/xmlhttprequest/workers/methods.html --iterations=100

would usually time out an iteration.

* NetworkProcess/cache/NetworkCacheStorageCocoa.mm:
(WebKit::NetworkCacheStorage::dispatchRetrieveOperation):

Using dispatch_io_read with an empty file calls the handler block immediately with done boolean set
without it being an error. We failed to call the completion handler and any synchronous xhr would hang.
We may see an empty cache file if we are just in process of writing it.

Fix by handling this case specifically.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179254 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm

index a36d513..90d0a65 100644 (file)
@@ -1,3 +1,25 @@
+2015-01-27  Antti Koivisto  <antti@apple.com>
+
+        http/tests/xmlhttprequest/workers/methods.html sometimes times out with disk cache enabled
+        https://bugs.webkit.org/show_bug.cgi?id=140976
+
+        Reviewed by Chris Dumez.
+
+        Running
+
+            run-webkit-tests --release -2 http/tests/xmlhttprequest/workers/methods.html --iterations=100
+
+        would usually time out an iteration.
+
+        * NetworkProcess/cache/NetworkCacheStorageCocoa.mm:
+        (WebKit::NetworkCacheStorage::dispatchRetrieveOperation):
+
+        Using dispatch_io_read with an empty file calls the handler block immediately with done boolean set
+        without it being an error. We failed to call the completion handler and any synchronous xhr would hang.
+        We may see an empty cache file if we are just in process of writing it.
+
+        Fix by handling this case specifically.
+
 2015-01-28  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Add missing file to WebInspector compilation for GTK+.
index a4da46a..571c5e7 100644 (file)
@@ -373,8 +373,12 @@ void NetworkCacheStorage::dispatchRetrieveOperation(const RetrieveOperation& ret
                 removeEntry(retrieve.key);
                 return;
             }
-            if (done)
+            if (done) {
+                // File exists but is empty. Invoke the completion handler as it hasn't been done yet.
+                if (fileData == dispatch_data_empty)
+                    retrieve.completionHandler(nullptr);
                 return;
+            }
             auto entry = decodeEntry(fileData, fd, retrieve.key);
             bool success = retrieve.completionHandler(WTF::move(entry));
             if (!success)