mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1136857 - Make DOMStorageCache::mLoaded flag atomic to prevent potential races, r=nfroyd
This commit is contained in:
parent
e0a3306fdd
commit
5e22931312
@ -564,9 +564,16 @@ DOMStorageCache::Clear(const DOMStorage* aStorage)
|
|||||||
void
|
void
|
||||||
DOMStorageCache::CloneFrom(const DOMStorageCache* aThat)
|
DOMStorageCache::CloneFrom(const DOMStorageCache* aThat)
|
||||||
{
|
{
|
||||||
mLoaded = aThat->mLoaded;
|
// This will never be called on anything else than SessionStorage.
|
||||||
|
// This means mData will never be touched on any other thread than
|
||||||
|
// the main thread and it never went through the loading process.
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
MOZ_ASSERT(!mPersistent);
|
||||||
|
MOZ_ASSERT(!(bool)aThat->mLoaded);
|
||||||
|
|
||||||
|
mLoaded = false;
|
||||||
mInitialized = aThat->mInitialized;
|
mInitialized = aThat->mInitialized;
|
||||||
mPersistent = aThat->mPersistent;
|
mPersistent = false;
|
||||||
mSessionOnlyDataSetActive = aThat->mSessionOnlyDataSetActive;
|
mSessionOnlyDataSetActive = aThat->mSessionOnlyDataSetActive;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < kDataSetCount; ++i) {
|
for (uint32_t i = 0; i < kDataSetCount; ++i) {
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "nsHashKeys.h"
|
#include "nsHashKeys.h"
|
||||||
#include "mozilla/Monitor.h"
|
#include "mozilla/Monitor.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
@ -220,8 +221,9 @@ private:
|
|||||||
// Flag that is initially false. When the cache is about to work with
|
// Flag that is initially false. When the cache is about to work with
|
||||||
// the database (i.e. it is persistent) this flags is set to true after
|
// the database (i.e. it is persistent) this flags is set to true after
|
||||||
// all keys and coresponding values are loaded from the database.
|
// all keys and coresponding values are loaded from the database.
|
||||||
// This flag never goes from true back to false.
|
// This flag never goes from true back to false. Since this flag is
|
||||||
bool mLoaded;
|
// critical for mData hashtable synchronization, it's made atomic.
|
||||||
|
Atomic<bool, ReleaseAcquire> mLoaded;
|
||||||
|
|
||||||
// Result of load from the database. Valid after mLoaded flag has been set.
|
// Result of load from the database. Valid after mLoaded flag has been set.
|
||||||
nsresult mLoadResult;
|
nsresult mLoadResult;
|
||||||
|
Loading…
Reference in New Issue
Block a user