Changeset 256426 in webkit


Ignore:
Timestamp:
Feb 11, 2020 10:15:24 PM (4 years ago)
Author:
youenn@apple.com
Message:

[ Mac Debug wk2 ] ASSERTION FAILED: m_wasConstructedOnMainThread == isMainThread()
https://bugs.webkit.org/show_bug.cgi?id=207509
<rdar://problem/59325466>

Reviewed by Chris Dumez.

Covered by existing tests.

  • NetworkProcess/cache/CacheStorageEngine.cpp:

(WebKit::CacheStorage::Engine::writeSizeFile):
Make sure completion handler is always called on the main thread.
Minor refactoring to make things more efficient.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r256420 r256426  
     12020-02-11  Youenn Fablet  <youenn@apple.com>
     2
     3        [ Mac Debug wk2 ] ASSERTION FAILED: m_wasConstructedOnMainThread == isMainThread()
     4        https://bugs.webkit.org/show_bug.cgi?id=207509
     5        <rdar://problem/59325466>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Covered by existing tests.
     10
     11        * NetworkProcess/cache/CacheStorageEngine.cpp:
     12        (WebKit::CacheStorage::Engine::writeSizeFile):
     13        Make sure completion handler is always called on the main thread.
     14        Minor refactoring to make things more efficient.
     15
    1162020-02-11  Fujii Hironori  <Hironori.Fujii@sony.com>
    217
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp

    r255876 r256426  
    531531void Engine::writeSizeFile(const String& path, uint64_t size, CompletionHandler<void()>&& completionHandler)
    532532{
    533     CompletionHandlerCallingScope completionHandlerCaller(WTFMove(completionHandler));
     533    ASSERT(RunLoop::isMain());
     534
    534535    if (!shouldPersist())
    535         return;
    536 
    537     m_ioQueue->dispatch([path = path.isolatedCopy(), size, completionHandlerCaller = WTFMove(completionHandlerCaller)]() mutable {
     536        return completionHandler();
     537
     538    m_ioQueue->dispatch([path = path.isolatedCopy(), size, completionHandler = WTFMove(completionHandler)]() mutable {
    538539        LockHolder locker(globalSizeFileLock);
    539540        auto fileHandle = FileSystem::openFile(path, FileSystem::FileOpenMode::Write);
    540         auto closeFileHandler = makeScopeExit([&] {
     541
     542        if (FileSystem::isHandleValid(fileHandle)) {
     543            FileSystem::truncateFile(fileHandle, 0);
     544
     545            auto value = String::number(size).utf8();
     546            FileSystem::writeToFile(fileHandle, value.data(), value.length());
     547
    541548            FileSystem::closeFile(fileHandle);
    542         });
    543         if (!FileSystem::isHandleValid(fileHandle))
    544             return;
    545 
    546         FileSystem::truncateFile(fileHandle, 0);
    547         FileSystem::writeToFile(fileHandle, String::number(size).utf8().data(), String::number(size).utf8().length());
    548 
    549         RunLoop::main().dispatch([completionHandlerCaller = WTFMove(completionHandlerCaller)]() mutable { });
     549        }
     550
     551        RunLoop::main().dispatch(WTFMove(completionHandler));
    550552    });
    551553}
Note: See TracChangeset for help on using the changeset viewer.