Changeset 179327 in webkit


Ignore:
Timestamp:
Jan 28, 2015, 6:52:30 PM (11 years ago)
Author:
Antti Koivisto
Message:

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.

The previous fix sometimes invoked the completion handler twice. Explicitly track if we
have called it or not.

  • NetworkProcess/cache/NetworkCacheStorageCocoa.mm:

(WebKit::NetworkCacheStorage::dispatchRetrieveOperation):

Also move the error case to the done branch. According to the documentation 'done' is always set on error.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r179326 r179327  
     12015-01-28  Antti Koivisto  <antti@apple.com>
     2
     3        http/tests/xmlhttprequest/workers/methods.html sometimes times out with disk cache enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=140976
     5
     6        Reviewed by Chris Dumez.
     7
     8        The previous fix sometimes invoked the completion handler twice. Explicitly track if we
     9        have called it or not.
     10
     11        * NetworkProcess/cache/NetworkCacheStorageCocoa.mm:
     12        (WebKit::NetworkCacheStorage::dispatchRetrieveOperation):
     13
     14        Also move the error case to the done branch. According to the documentation 'done' is always set on error.
     15
    1162015-01-28  Timothy Horton  <timothy_horton@apple.com>
    217
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm

    r179254 r179327  
    363363        auto channel = createIOChannelForKey(retrieve.key, IOChannelType::Read, cachePathCapture.string(), fd);
    364364
    365         dispatch_io_read(channel.get(), 0, std::numeric_limits<size_t>::max(), dispatch_get_main_queue(), [this, fd, retrieve](bool done, dispatch_data_t fileData, int error) {
     365        bool didCallCompletionHandler = false;
     366        dispatch_io_read(channel.get(), 0, std::numeric_limits<size_t>::max(), dispatch_get_main_queue(), [this, fd, retrieve, didCallCompletionHandler](bool done, dispatch_data_t fileData, int error) mutable {
    366367            if (done) {
    367368                ASSERT(m_activeRetrieveOperationCount);
     
    369370                dispatchPendingRetrieveOperations();
    370371            }
    371             if (error) {
    372                 retrieve.completionHandler(nullptr);
    373                 removeEntry(retrieve.key);
     372            if (done) {
     373                if (!didCallCompletionHandler)
     374                    retrieve.completionHandler(nullptr);
     375                if (error)
     376                    removeEntry(retrieve.key);
    374377                return;
    375378            }
    376             if (done) {
    377                 // File exists but is empty. Invoke the completion handler as it hasn't been done yet.
    378                 if (fileData == dispatch_data_empty)
    379                     retrieve.completionHandler(nullptr);
    380                 return;
    381             }
     379            ASSERT(!didCallCompletionHandler); // We are requesting maximum sized chunk so we should never get called more than once with data.
     380
    382381            auto entry = decodeEntry(fileData, fd, retrieve.key);
    383382            bool success = retrieve.completionHandler(WTF::move(entry));
     383            didCallCompletionHandler = true;
    384384            if (!success)
    385385                removeEntry(retrieve.key);
Note: See TracChangeset for help on using the changeset viewer.