Skip to content
Permalink
Browse files
Caches::m_storage should be set to null in case of error at initializ…
…ation time

https://bugs.webkit.org/show_bug.cgi?id=183068

Patch by Youenn Fablet <youenn@apple.com> on 2018-02-26
Reviewed by Chris Dumez.

In case of error, we need to set m_storage back to nullptr so that
next tries to initialize it will restart from scratch.
If we do not set it to nullptr, we end up storing the initialize
callback in a queue and the callback will never be called.

This is difficult to test as we need the following conditions:
- we need to have an error case, like a disk writing error
- we need the web app to open a cache in two different pages/frames at about the same time.

* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::Caches::initialize):

Canonical link: https://commits.webkit.org/198860@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229045 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf authored and webkit-commit-queue committed Feb 27, 2018
1 parent 3de37bf commit 1533630dea44069c64924505e410220e2d70a8a0
Showing with 23 additions and 0 deletions.
  1. +19 −0 Source/WebKit/ChangeLog
  2. +4 −0 Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp
@@ -1,3 +1,22 @@
2018-02-26 Youenn Fablet <youenn@apple.com>

Caches::m_storage should be set to null in case of error at initialization time
https://bugs.webkit.org/show_bug.cgi?id=183068

Reviewed by Chris Dumez.

In case of error, we need to set m_storage back to nullptr so that
next tries to initialize it will restart from scratch.
If we do not set it to nullptr, we end up storing the initialize
callback in a queue and the callback will never be called.

This is difficult to test as we need the following conditions:
- we need to have an error case, like a disk writing error
- we need the web app to open a cache in two different pages/frames at about the same time.

* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::Caches::initialize):

2018-02-26 Commit Queue <commit-queue@webkit.org>

Unreviewed, rolling out r226330.
@@ -154,6 +154,8 @@ void Caches::initialize(WebCore::DOMCacheEngine::CompletionCallback&& callback)
auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
for (auto& callback : pendingCallbacks)
callback(Error::WriteDisk);

m_storage = nullptr;
return;
}

@@ -166,6 +168,8 @@ void Caches::initialize(WebCore::DOMCacheEngine::CompletionCallback&& callback)
auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
for (auto& callback : pendingCallbacks)
callback(result.error());

m_storage = nullptr;
return;
}
m_caches = WTFMove(result.value());

0 comments on commit 1533630

Please sign in to comment.