Title: [168596] trunk/Source/WebCore
Revision
168596
Author
commit-qu...@webkit.org
Date
2014-05-11 00:01:15 -0700 (Sun, 11 May 2014)

Log Message

WinCairo crashes on acid3 test
https://bugs.webkit.org/show_bug.cgi?id=131364

Patch by pe...@outlook.com <pe...@outlook.com> on 2014-05-11
Reviewed by Brent Fulgham.

When the 304 (Not-modified) response is received, the Curl backend should look up the cached response,
and call the client method didReceiveResponse with the cached response, instead of the 304 response.
Otherwise the response will contain an empty MIME type, which causes the request to be cancelled, and the client deleted.
When the Curl cache manager then accesses the client afterwards, it is deleted, and we crash.

* platform/network/curl/CurlCacheManager.cpp:
(WebCore::CurlCacheManager::didReceiveResponse): Return early if request is cancelled.
(WebCore::CurlCacheManager::getCachedResponse): Added method to get cached response.
* platform/network/curl/CurlCacheManager.h: Ditto.
* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::headerCallback): When 304 response is received, look up cached response, and use it.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (168595 => 168596)


--- trunk/Source/WebCore/ChangeLog	2014-05-11 05:30:54 UTC (rev 168595)
+++ trunk/Source/WebCore/ChangeLog	2014-05-11 07:01:15 UTC (rev 168596)
@@ -1,3 +1,22 @@
+2014-05-11  pe...@outlook.com  <pe...@outlook.com>
+
+        WinCairo crashes on acid3 test
+        https://bugs.webkit.org/show_bug.cgi?id=131364
+
+        Reviewed by Brent Fulgham.
+
+        When the 304 (Not-modified) response is received, the Curl backend should look up the cached response,
+        and call the client method didReceiveResponse with the cached response, instead of the 304 response.
+        Otherwise the response will contain an empty MIME type, which causes the request to be cancelled, and the client deleted.
+        When the Curl cache manager then accesses the client afterwards, it is deleted, and we crash.
+
+        * platform/network/curl/CurlCacheManager.cpp:
+        (WebCore::CurlCacheManager::didReceiveResponse): Return early if request is cancelled.
+        (WebCore::CurlCacheManager::getCachedResponse): Added method to get cached response.
+        * platform/network/curl/CurlCacheManager.h: Ditto.
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::headerCallback): When 304 response is received, look up cached response, and use it.
+
 2014-05-10  Tim Horton  <timothy_hor...@apple.com>
 
         [WKWebView _updateScrollViewBackground] churns UI-and-CGColors while repainting

Modified: trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp (168595 => 168596)


--- trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2014-05-11 05:30:54 UTC (rev 168595)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2014-05-11 07:01:15 UTC (rev 168596)
@@ -196,6 +196,10 @@
     if (m_disabled)
         return;
 
+    ResourceHandleInternal* d = job->getInternal();
+    if (d->m_cancelled)
+        return;
+
     String url = ""
 
     if (response.httpStatusCode() == 304) {
@@ -247,6 +251,16 @@
     return m_index.find(url)->value->requestHeaders();
 }
 
+bool CurlCacheManager::getCachedResponse(const String& url, ResourceResponse& response)
+{
+    HashMap<String, std::unique_ptr<CurlCacheEntry>>::iterator it = m_index.find(url);
+    if (it != m_index.end()) {
+        it->value->setResponseFromCachedHeaders(response);
+        return true;
+    }
+    return false;
+}
+
 void CurlCacheManager::didReceiveData(const String& url, const char* data, size_t size)
 {
     if (m_disabled)

Modified: trunk/Source/WebCore/platform/network/curl/CurlCacheManager.h (168595 => 168596)


--- trunk/Source/WebCore/platform/network/curl/CurlCacheManager.h	2014-05-11 05:30:54 UTC (rev 168595)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheManager.h	2014-05-11 07:01:15 UTC (rev 168596)
@@ -47,6 +47,7 @@
 
     bool isCached(const String&);
     HTTPHeaderMap& requestHeaders(const String&); // Load headers
+    bool getCachedResponse(const String& url, ResourceResponse&);
 
     void didReceiveResponse(ResourceHandle*, ResourceResponse&);
     void didReceiveData(const String&, const char*, size_t); // Save data

Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp (168595 => 168596)


--- trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp	2014-05-11 05:30:54 UTC (rev 168595)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp	2014-05-11 07:01:15 UTC (rev 168596)
@@ -532,7 +532,11 @@
         }
 
         if (client) {
-            client->didReceiveResponse(job, d->m_response); 
+            if (httpCode == 304) {
+                const String& url = ""
+                CurlCacheManager::getInstance().getCachedResponse(url, d->m_response);
+            }
+            client->didReceiveResponse(job, d->m_response);
             CurlCacheManager::getInstance().didReceiveResponse(job, d->m_response);
         }
         d->m_response.setResponseFired(true);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to