Changeset 229172 in webkit


Ignore:
Timestamp:
Mar 2, 2018 8:52:32 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

IOChannel::read and IOChannel::write can destroy the completion handler in the thread used to manipulate thread
https://bugs.webkit.org/show_bug.cgi?id=183261

Patch by Youenn Fablet <youenn@apple.com> on 2018-03-02
Reviewed by Antti Koivisto.

Moving the completion handler when being called so that it gets desttroyed in the thread it is called.

  • NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:

(WebKit::NetworkCache::IOChannel::read):
(WebKit::NetworkCache::IOChannel::write):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r229168 r229172  
     12018-03-02  Youenn Fablet  <youenn@apple.com>
     2
     3        IOChannel::read and IOChannel::write can destroy the completion handler in the thread used to manipulate thread
     4        https://bugs.webkit.org/show_bug.cgi?id=183261
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Moving the completion handler when being called so that it gets desttroyed in the thread it is called.
     9
     10        * NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
     11        (WebKit::NetworkCache::IOChannel::read):
     12        (WebKit::NetworkCache::IOChannel::write):
     13
    1142018-03-02  Dan Bernstein  <mitz@apple.com>
    215
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm

    r224371 r229172  
    103103        DispatchPtr<dispatch_data_t> fileDataPtr(fileData);
    104104        Data data(fileDataPtr);
    105         completionHandler(data, error);
     105        auto callback = WTFMove(completionHandler);
     106        callback(data, error);
    106107        didCallCompletionHandler = true;
    107108    }).get());
     
    113114    auto dispatchData = data.dispatchData();
    114115    auto dispatchQueue = queue ? queue->dispatchQueue() : dispatch_get_main_queue();
    115     dispatch_io_write(m_dispatchIO.get(), offset, dispatchData, dispatchQueue, BlockPtr<void(bool, dispatch_data_t, int)>::fromCallable([channel, completionHandler = WTFMove(completionHandler)](bool done, dispatch_data_t fileData, int error) {
     116    dispatch_io_write(m_dispatchIO.get(), offset, dispatchData, dispatchQueue, BlockPtr<void(bool, dispatch_data_t, int)>::fromCallable([channel, completionHandler = WTFMove(completionHandler)](bool done, dispatch_data_t fileData, int error) mutable {
    116117        ASSERT_UNUSED(done, done);
    117         completionHandler(error);
     118        auto callback = WTFMove(completionHandler);
     119        callback(error);
    118120    }).get());
    119121}
Note: See TracChangeset for help on using the changeset viewer.