Changeset 173666 in webkit


Ignore:
Timestamp:
Sep 16, 2014 12:22:39 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[Curl] Sometimes incomplete or empty content can be loaded from cache.
https://bugs.webkit.org/show_bug.cgi?id=136855

Patch by peavo@outlook.com <peavo@outlook.com> on 2014-09-16
Reviewed by Alex Christensen.

Sometimes, when two requests with the same url are started at the same time,
there is a possibility of loading incomplete or empty content from the cache.
This happens because the method CurlCacheEntry::isLoading() is returning the wrong status
in the time period between the headers are received, and the content data is received.
This can be fixed by using a flag for the load status, instead of checking whether
the content file is open.

  • platform/network/curl/CurlCacheEntry.cpp:

(WebCore::CurlCacheEntry::CurlCacheEntry): Initialize loading flag.
(WebCore::CurlCacheEntry::isLoading): Return loading flag.
(WebCore::CurlCacheEntry::didFail): Call new method to set loading flag.
(WebCore::CurlCacheEntry::didFinishLoading): Ditto.
(WebCore::CurlCacheEntry::setIsLoading): Added new method to set loading flag.

  • platform/network/curl/CurlCacheEntry.h: Added loading flag and new method to set it.
  • platform/network/curl/CurlCacheManager.cpp:

(WebCore::CurlCacheManager::didReceiveResponse): Call new method to set loading flag.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r173665 r173666  
     12014-09-16  peavo@outlook.com  <peavo@outlook.com>
     2
     3        [Curl] Sometimes incomplete or empty content can be loaded from cache.
     4        https://bugs.webkit.org/show_bug.cgi?id=136855
     5
     6        Reviewed by Alex Christensen.
     7
     8        Sometimes, when two requests with the same url are started at the same time,
     9        there is a possibility of loading incomplete or empty content from the cache.
     10        This happens because the method CurlCacheEntry::isLoading() is returning the wrong status
     11        in the time period between the headers are received, and the content data is received.
     12        This can be fixed by using a flag for the load status, instead of checking whether
     13        the content file is open.
     14
     15        * platform/network/curl/CurlCacheEntry.cpp:
     16        (WebCore::CurlCacheEntry::CurlCacheEntry): Initialize loading flag.
     17        (WebCore::CurlCacheEntry::isLoading): Return loading flag.
     18        (WebCore::CurlCacheEntry::didFail): Call new method to set loading flag.
     19        (WebCore::CurlCacheEntry::didFinishLoading): Ditto.
     20        (WebCore::CurlCacheEntry::setIsLoading): Added new method to set loading flag.
     21        * platform/network/curl/CurlCacheEntry.h: Added loading flag and new method to set it.
     22        * platform/network/curl/CurlCacheManager.cpp:
     23        (WebCore::CurlCacheManager::didReceiveResponse): Call new method to set loading flag.
     24
    1252014-09-16  Chris Dumez  <cdumez@apple.com>
    226
  • trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp

    r173350 r173666  
    5454    , m_expireDate(-1)
    5555    , m_headerParsed(false)
     56    , m_isLoading(false)
    5657    , m_job(job)
    5758{
     
    7071}
    7172
    72 bool CurlCacheEntry::isLoading()
    73 {
    74     return isHandleValid(m_contentFile);
     73bool CurlCacheEntry::isLoading() const
     74{
     75    return m_isLoading;
    7576}
    7677
     
    116117        return false;
    117118
    118     job->getInternal()->client()->didReceiveData(job, buffer.data(), buffer.size(), 0);
     119    if (buffer.size())
     120        job->getInternal()->client()->didReceiveData(job, buffer.data(), buffer.size(), 0);
     121
    119122    return true;
    120123}
     
    200203{
    201204    // The cache manager will call invalidate()
    202     closeContentFile();
     205    setIsLoading(false);
    203206}
    204207
    205208void CurlCacheEntry::didFinishLoading()
    206209{
    207     closeContentFile();
     210    setIsLoading(false);
    208211}
    209212
     
    347350}
    348351
     352void CurlCacheEntry::setIsLoading(bool isLoading)
     353{
     354    m_isLoading = isLoading;
     355    if (m_isLoading)
     356        openContentFile();
     357    else
     358        closeContentFile();
     359}
     360
    349361size_t CurlCacheEntry::entrySize()
    350362{
  • trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.h

    r169811 r173666  
    4646
    4747    bool isCached();
    48     bool isLoading();
     48    bool isLoading() const;
    4949    size_t entrySize();
    5050    HTTPHeaderMap& requestHeaders() { return m_requestHeaders; }
     
    6262    bool parseResponseHeaders(const ResourceResponse&);
    6363
     64    void setIsLoading(bool);
     65
    6466    const ResourceHandle* getJob() const { return m_job; }
    6567
     
    7476    double m_expireDate;
    7577    bool m_headerParsed;
     78    bool m_isLoading;
    7679
    7780    ResourceResponse m_cachedResponse;
  • trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp

    r173358 r173666  
    219219        bool cacheable = cacheEntry->parseResponseHeaders(response);
    220220        if (cacheable) {
     221            cacheEntry->setIsLoading(true);
    221222            m_LRUEntryList.prependOrMoveToFirst(url);
    222223            m_index.set(url, WTF::move(cacheEntry));
Note: See TracChangeset for help on using the changeset viewer.