Title: [256972] branches/safari-609.1.20.1-branch/Source/WebKit
Revision
256972
Author
repst...@apple.com
Date
2020-02-19 15:37:38 -0800 (Wed, 19 Feb 2020)

Log Message

Cherry-pick r256426. rdar://problem/59576790

    [ 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.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256426 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-609.1.20.1-branch/Source/WebKit/ChangeLog (256971 => 256972)


--- branches/safari-609.1.20.1-branch/Source/WebKit/ChangeLog	2020-02-19 23:37:33 UTC (rev 256971)
+++ branches/safari-609.1.20.1-branch/Source/WebKit/ChangeLog	2020-02-19 23:37:38 UTC (rev 256972)
@@ -1,5 +1,40 @@
 2020-02-19  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r256426. rdar://problem/59576790
+
+    [ 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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256426 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-02-11  Youenn Fablet  <you...@apple.com>
+
+            [ 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.
+
+2020-02-19  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r256314. rdar://problem/59576791
 
     WebSWServerConnection::registerServiceWorkerClient is not sending IPC message to UIProcess when it should

Modified: branches/safari-609.1.20.1-branch/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (256971 => 256972)


--- branches/safari-609.1.20.1-branch/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2020-02-19 23:37:33 UTC (rev 256971)
+++ branches/safari-609.1.20.1-branch/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2020-02-19 23:37:38 UTC (rev 256972)
@@ -530,23 +530,25 @@
 
 void Engine::writeSizeFile(const String& path, uint64_t size, CompletionHandler<void()>&& completionHandler)
 {
-    CompletionHandlerCallingScope completionHandlerCaller(WTFMove(completionHandler));
+    ASSERT(RunLoop::isMain());
+
     if (!shouldPersist())
-        return;
+        return completionHandler();
 
-    m_ioQueue->dispatch([path = path.isolatedCopy(), size, completionHandlerCaller = WTFMove(completionHandlerCaller)]() mutable {
+    m_ioQueue->dispatch([path = path.isolatedCopy(), size, completionHandler = WTFMove(completionHandler)]() mutable {
         LockHolder locker(globalSizeFileLock);
         auto fileHandle = FileSystem::openFile(path, FileSystem::FileOpenMode::Write);
-        auto closeFileHandler = makeScopeExit([&] {
+
+        if (FileSystem::isHandleValid(fileHandle)) {
+            FileSystem::truncateFile(fileHandle, 0);
+
+            auto value = String::number(size).utf8();
+            FileSystem::writeToFile(fileHandle, value.data(), value.length());
+
             FileSystem::closeFile(fileHandle);
-        });
-        if (!FileSystem::isHandleValid(fileHandle))
-            return;
+        }
 
-        FileSystem::truncateFile(fileHandle, 0);
-        FileSystem::writeToFile(fileHandle, String::number(size).utf8().data(), String::number(size).utf8().length());
-
-        RunLoop::main().dispatch([completionHandlerCaller = WTFMove(completionHandlerCaller)]() mutable { });
+        RunLoop::main().dispatch(WTFMove(completionHandler));
     });
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to