svn commit: r459395 - in branches/2018Q1/www/waterfox: . files
Jan Beich
jbeich at FreeBSD.org
Fri Jan 19 05:01:14 UTC 2018
Author: jbeich
Date: Fri Jan 19 05:01:12 2018
New Revision: 459395
URL: https://svnweb.freebsd.org/changeset/ports/459395
Log:
MFH: r459394
www/waterfox: apply more FF58 fixes
Security: a891c5b4-3d7a-4de9-9c71-eef3fd698c77
Approved by: ports-secteam blanket
Added:
branches/2018Q1/www/waterfox/files/patch-bug1331209
- copied unchanged from r459394, head/www/waterfox/files/patch-bug1331209
branches/2018Q1/www/waterfox/files/patch-bug1389561
- copied unchanged from r459394, head/www/waterfox/files/patch-bug1389561
branches/2018Q1/www/waterfox/files/patch-bug1425612
- copied unchanged from r459394, head/www/waterfox/files/patch-bug1425612
branches/2018Q1/www/waterfox/files/patch-bug1426783
- copied unchanged from r459394, head/www/waterfox/files/patch-bug1426783
branches/2018Q1/www/waterfox/files/patch-bug1429764
- copied unchanged from r459394, head/www/waterfox/files/patch-bug1429764
branches/2018Q1/www/waterfox/files/patch-bug1430508
- copied unchanged from r459394, head/www/waterfox/files/patch-bug1430508
Modified:
branches/2018Q1/www/waterfox/Makefile
Directory Properties:
branches/2018Q1/ (props changed)
Modified: branches/2018Q1/www/waterfox/Makefile
==============================================================================
--- branches/2018Q1/www/waterfox/Makefile Fri Jan 19 04:50:36 2018 (r459394)
+++ branches/2018Q1/www/waterfox/Makefile Fri Jan 19 05:01:12 2018 (r459395)
@@ -2,7 +2,7 @@
PORTNAME= waterfox
DISTVERSION= 56.0.3
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= www ipv6
MAINTAINER= jbeich at FreeBSD.org
Copied: branches/2018Q1/www/waterfox/files/patch-bug1331209 (from r459394, head/www/waterfox/files/patch-bug1331209)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/2018Q1/www/waterfox/files/patch-bug1331209 Fri Jan 19 05:01:12 2018 (r459395, copy of r459394, head/www/waterfox/files/patch-bug1331209)
@@ -0,0 +1,571 @@
+commit b7088851d6e8
+Author: Jan Varga <jan.varga at gmail.com>
+Date: Sat Nov 4 23:13:20 2017 +0100
+
+ Bug 1331209 - Part 2: Fix incorrect FailOnNonOwningThread() calls; r=asuth
+---
+ dom/asmjscache/AsmJSCache.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git dom/asmjscache/AsmJSCache.cpp dom/asmjscache/AsmJSCache.cpp
+index 227bf80f2ac4..ec1e3531fb4f 100644
+--- dom/asmjscache/AsmJSCache.cpp
++++ dom/asmjscache/AsmJSCache.cpp
+@@ -560,13 +560,13 @@ private:
+ // If shutdown just started, the QuotaManager may have been deleted.
+ QuotaManager* qm = QuotaManager::Get();
+ if (!qm) {
+- FailOnNonOwningThread();
++ Fail();
+ return;
+ }
+
+ nsresult rv = qm->IOThread()->Dispatch(this, NS_DISPATCH_NORMAL);
+ if (NS_FAILED(rv)) {
+- FailOnNonOwningThread();
++ Fail();
+ return;
+ }
+ }
+
+commit ea39dafe977a
+Author: Jan Varga <jan.varga at gmail.com>
+Date: Sat Nov 4 23:13:41 2017 +0100
+
+ Bug 1331209 - Part 3: Allow sending of the __delete__ message in one direction only; r=asuth
+---
+ dom/asmjscache/AsmJSCache.cpp | 141 +++++++++++++++++++++++------------
+ dom/asmjscache/PAsmJSCacheEntry.ipdl | 20 ++++-
+ 2 files changed, 111 insertions(+), 50 deletions(-)
+
+diff --git dom/asmjscache/AsmJSCache.cpp dom/asmjscache/AsmJSCache.cpp
+index ec1e3531fb4f..2216149cd762 100644
+--- dom/asmjscache/AsmJSCache.cpp
++++ dom/asmjscache/AsmJSCache.cpp
+@@ -445,7 +445,6 @@ public:
+ mWriteParams(aWriteParams),
+ mState(eInitial),
+ mResult(JS::AsmJSCache_InternalError),
+- mDeleteReceived(false),
+ mActorDestroyed(false),
+ mOpened(false)
+ {
+@@ -493,12 +492,17 @@ private:
+ {
+ AssertIsOnOwningThread();
+ MOZ_ASSERT(mState == eOpened);
++ MOZ_ASSERT(mResult == JS::AsmJSCache_Success);
+
+ mState = eFinished;
+
+ MOZ_ASSERT(mOpened);
+
+ FinishOnOwningThread();
++
++ if (!mActorDestroyed) {
++ Unused << Send__delete__(this, mResult);
++ }
+ }
+
+ // This method is called upon any failure that prevents the eventual opening
+@@ -508,6 +512,7 @@ private:
+ {
+ AssertIsOnOwningThread();
+ MOZ_ASSERT(mState != eFinished);
++ MOZ_ASSERT(mResult != JS::AsmJSCache_Success);
+
+ mState = eFinished;
+
+@@ -515,7 +520,7 @@ private:
+
+ FinishOnOwningThread();
+
+- if (!mDeleteReceived && !mActorDestroyed) {
++ if (!mActorDestroyed) {
+ Unused << Send__delete__(this, mResult);
+ }
+ }
+@@ -579,26 +584,6 @@ private:
+ DirectoryLockFailed() override;
+
+ // IPDL methods.
+- mozilla::ipc::IPCResult
+- Recv__delete__(const JS::AsmJSCacheResult& aResult) override
+- {
+- AssertIsOnOwningThread();
+- MOZ_ASSERT(mState != eFinished);
+- MOZ_ASSERT(!mDeleteReceived);
+-
+- mDeleteReceived = true;
+-
+- if (mOpened) {
+- Close();
+- } else {
+- Fail();
+- }
+-
+- MOZ_ASSERT(mState == eFinished);
+-
+- return IPC_OK();
+- }
+-
+ void
+ ActorDestroy(ActorDestroyReason why) override
+ {
+@@ -624,17 +609,59 @@ private:
+ }
+
+ mozilla::ipc::IPCResult
+- RecvSelectCacheFileToRead(const uint32_t& aModuleIndex) override
++ RecvSelectCacheFileToRead(const OpenMetadataForReadResponse& aResponse)
++ override
+ {
+ AssertIsOnOwningThread();
+ MOZ_ASSERT(mState == eWaitingToOpenCacheFileForRead);
+ MOZ_ASSERT(mOpenMode == eOpenForRead);
++ MOZ_ASSERT(!mOpened);
++
++ switch (aResponse.type()) {
++ case OpenMetadataForReadResponse::TAsmJSCacheResult: {
++ MOZ_ASSERT(aResponse.get_AsmJSCacheResult() != JS::AsmJSCache_Success);
++
++ mResult = aResponse.get_AsmJSCacheResult();
++
++ // This ParentRunnable can only be held alive by the IPDL. Fail()
++ // clears that last reference. So we need to add a self reference here.
++ RefPtr<ParentRunnable> kungFuDeathGrip = this;
++
++ Fail();
++
++ break;
++ }
++
++ case OpenMetadataForReadResponse::Tuint32_t:
++ // A cache entry has been selected to open.
++ mModuleIndex = aResponse.get_uint32_t();
++
++ mState = eReadyToOpenCacheFileForRead;
++
++ DispatchToIOThread();
++
++ break;
+
+- // A cache entry has been selected to open.
++ default:
++ MOZ_CRASH("Should never get here!");
++ }
++
++ return IPC_OK();
++ }
++
++ mozilla::ipc::IPCResult
++ RecvClose() override
++ {
++ AssertIsOnOwningThread();
++ MOZ_ASSERT(mState == eOpened);
+
+- mModuleIndex = aModuleIndex;
+- mState = eReadyToOpenCacheFileForRead;
+- DispatchToIOThread();
++ // This ParentRunnable can only be held alive by the IPDL. Close() clears
++ // that last reference. So we need to add a self reference here.
++ RefPtr<ParentRunnable> kungFuDeathGrip = this;
++
++ Close();
++
++ MOZ_ASSERT(mState == eFinished);
+
+ return IPC_OK();
+ }
+@@ -675,7 +702,6 @@ private:
+ State mState;
+ JS::AsmJSCacheResult mResult;
+
+- bool mDeleteReceived;
+ bool mActorDestroyed;
+ bool mOpened;
+ };
+@@ -1021,10 +1047,6 @@ ParentRunnable::Run()
+
+ mState = eOpened;
+
+- // The entry is now open.
+- MOZ_ASSERT(!mOpened);
+- mOpened = true;
+-
+ FileDescriptor::PlatformHandleType handle =
+ FileDescriptor::PlatformHandleType(PR_FileDesc2NativeHandle(mFileDesc));
+ if (!SendOnOpenCacheFile(mFileSize, FileDescriptor(handle))) {
+@@ -1032,6 +1054,12 @@ ParentRunnable::Run()
+ return NS_OK;
+ }
+
++ // The entry is now open.
++ MOZ_ASSERT(!mOpened);
++ mOpened = true;
++
++ mResult = JS::AsmJSCache_Success;
++
+ return NS_OK;
+ }
+
+@@ -1291,15 +1319,16 @@ private:
+ MOZ_ASSERT(mState == eOpening);
+
+ uint32_t moduleIndex;
+- if (!FindHashMatch(aMetadata, mReadParams, &moduleIndex)) {
+- Fail(JS::AsmJSCache_InternalError);
+- Send__delete__(this, JS::AsmJSCache_InternalError);
+- return IPC_OK();
++ bool ok;
++ if (FindHashMatch(aMetadata, mReadParams, &moduleIndex)) {
++ ok = SendSelectCacheFileToRead(moduleIndex);
++ } else {
++ ok = SendSelectCacheFileToRead(JS::AsmJSCache_InternalError);
+ }
+-
+- if (!SendSelectCacheFileToRead(moduleIndex)) {
++ if (!ok) {
+ return IPC_FAIL_NO_REASON(this);
+ }
++
+ return IPC_OK();
+ }
+
+@@ -1327,9 +1356,20 @@ private:
+ Recv__delete__(const JS::AsmJSCacheResult& aResult) override
+ {
+ MOZ_ASSERT(NS_IsMainThread());
+- MOZ_ASSERT(mState == eOpening);
++ MOZ_ASSERT(mState == eOpening || mState == eFinishing);
++ MOZ_ASSERT_IF(mState == eOpening, aResult != JS::AsmJSCache_Success);
++ MOZ_ASSERT_IF(mState == eFinishing, aResult == JS::AsmJSCache_Success);
+
+- Fail(aResult);
++ if (mState == eOpening) {
++ Fail(aResult);
++ } else {
++ // Match the AddRef in BlockUntilOpen(). The IPDL still holds an
++ // outstanding ref which will keep 'this' alive until ActorDestroy()
++ // is executed.
++ Release();
++
++ mState = eFinished;
++ }
+ return IPC_OK();
+ }
+
+@@ -1395,6 +1435,7 @@ private:
+ eOpening, // Waiting for the parent process to respond
+ eOpened, // Parent process opened the entry and sent it back
+ eClosing, // Waiting to be dispatched to the main thread to Send__delete__
++ eFinishing, // Waiting for the parent process to close
+ eFinished // Terminal state
+ };
+ State mState;
+@@ -1454,28 +1495,32 @@ ChildRunnable::Run()
+
+ // Per FileDescriptorHolder::Finish()'s comment, call before
+ // releasing the directory lock (which happens in the parent upon receipt
+- // of the Send__delete__ message).
++ // of the Close message).
+ FileDescriptorHolder::Finish();
+
+ MOZ_ASSERT(mOpened);
+ mOpened = false;
+
+- // Match the AddRef in BlockUntilOpen(). The main thread event loop still
+- // holds an outstanding ref which will keep 'this' alive until returning to
+- // the event loop.
+- Release();
++ if (mActorDestroyed) {
++ // Match the AddRef in BlockUntilOpen(). The main thread event loop
++ // still holds an outstanding ref which will keep 'this' alive until
++ // returning to the event loop.
++ Release();
+
+- if (!mActorDestroyed) {
+- Unused << Send__delete__(this, JS::AsmJSCache_Success);
++ mState = eFinished;
++ } else {
++ Unused << SendClose();
++
++ mState = eFinishing;
+ }
+
+- mState = eFinished;
+ return NS_OK;
+ }
+
+ case eBackgroundChildPending:
+ case eOpening:
+ case eOpened:
++ case eFinishing:
+ case eFinished: {
+ MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Shouldn't Run() in this state");
+ }
+diff --git dom/asmjscache/PAsmJSCacheEntry.ipdl dom/asmjscache/PAsmJSCacheEntry.ipdl
+index d16c9284ff9d..bb88a25b5615 100644
+--- dom/asmjscache/PAsmJSCacheEntry.ipdl
++++ dom/asmjscache/PAsmJSCacheEntry.ipdl
+@@ -11,6 +11,12 @@ namespace mozilla {
+ namespace dom {
+ namespace asmjscache {
+
++union OpenMetadataForReadResponse
++{
++ AsmJSCacheResult;
++ uint32_t;
++};
++
+ protocol PAsmJSCacheEntry
+ {
+ manager PBackground;
+@@ -21,14 +27,24 @@ protocol PAsmJSCacheEntry
+ child:
+ async OnOpenMetadataForRead(Metadata metadata);
+ parent:
+- async SelectCacheFileToRead(uint32_t moduleIndex);
++ async SelectCacheFileToRead(OpenMetadataForReadResponse response);
+
+ child:
+ // Once the cache file has been opened, the child is notified and sent an
+ // open file descriptor.
+ async OnOpenCacheFile(int64_t fileSize, FileDescriptor fileDesc);
+
+-both:
++parent:
++ // When the child process is done with the cache entry, the parent process
++ // is notified (via Close).
++ async Close();
++
++child:
++ // When there's an error during the opening phase, the child process is
++ // notified (via __delete__) and sent an error result.
++ // When the parent process receives the Close message, it closes the cache
++ // entry on the parent side and the child is notified (via __delete__).
++ // The protocol is destroyed in both cases.
+ async __delete__(AsmJSCacheResult result);
+ };
+
+
+commit 04d80fd8932a
+Author: Jan Varga <jan.varga at gmail.com>
+Date: Sat Nov 4 23:13:51 2017 +0100
+
+ Bug 1331209 - Part 4: Prevent the state machine from continuing if QM is shutting down or the actor has been destroyed; r=asuth
+---
+ dom/asmjscache/AsmJSCache.cpp | 97 +++++++++++++++++++++++++++++++++++++------
+ 1 file changed, 84 insertions(+), 13 deletions(-)
+
+diff --git dom/asmjscache/AsmJSCache.cpp dom/asmjscache/AsmJSCache.cpp
+index 2216149cd762..7c96bc71ac0a 100644
+--- dom/asmjscache/AsmJSCache.cpp
++++ dom/asmjscache/AsmJSCache.cpp
+@@ -443,6 +443,7 @@ public:
+ mPrincipalInfo(aPrincipalInfo),
+ mOpenMode(aOpenMode),
+ mWriteParams(aWriteParams),
++ mOperationMayProceed(true),
+ mState(eInitial),
+ mResult(JS::AsmJSCache_InternalError),
+ mActorDestroyed(false),
+@@ -485,6 +486,22 @@ private:
+ MOZ_ASSERT(!IsOnOwningThread());
+ }
+
++ bool
++ IsActorDestroyed() const
++ {
++ AssertIsOnOwningThread();
++
++ return mActorDestroyed;
++ }
++
++ // May be called on any thread, but you should call IsActorDestroyed() if
++ // you know you're on the background thread because it is slightly faster.
++ bool
++ OperationMayProceed() const
++ {
++ return mOperationMayProceed;
++ }
++
+ // This method is called on the owning thread when the JS engine is finished
+ // reading/writing the cache entry.
+ void
+@@ -497,6 +514,7 @@ private:
+ mState = eFinished;
+
+ MOZ_ASSERT(mOpened);
++ mOpened = false;
+
+ FinishOnOwningThread();
+
+@@ -562,13 +580,15 @@ private:
+ {
+ AssertIsOnOwningThread();
+
+- // If shutdown just started, the QuotaManager may have been deleted.
+- QuotaManager* qm = QuotaManager::Get();
+- if (!qm) {
++ if (NS_WARN_IF(Client::IsShuttingDownOnBackgroundThread()) ||
++ IsActorDestroyed()) {
+ Fail();
+ return;
+ }
+
++ QuotaManager* qm = QuotaManager::Get();
++ MOZ_ASSERT(qm);
++
+ nsresult rv = qm->IOThread()->Dispatch(this, NS_DISPATCH_NORMAL);
+ if (NS_FAILED(rv)) {
+ Fail();
+@@ -589,23 +609,30 @@ private:
+ {
+ AssertIsOnOwningThread();
+ MOZ_ASSERT(!mActorDestroyed);
++ MOZ_ASSERT(mOperationMayProceed);
+
+ mActorDestroyed = true;
++ mOperationMayProceed = false;
+
+- // Assume ActorDestroy can happen at any time, so probe the current state to
+- // determine what needs to happen.
+-
+- if (mState == eFinished) {
+- return;
+- }
++ // Assume ActorDestroy can happen at any time, so we can't probe the
++ // current state since mState can be modified on any thread (only one
++ // thread at a time based on the state machine).
++ // However we can use mOpened which is only touched on the owning thread.
++ // If mOpened is true, we can also modify mState since we are guaranteed
++ // that there are no pending runnables which would probe mState to decide
++ // what code needs to run (there shouldn't be any running runnables on
++ // other threads either).
+
+ if (mOpened) {
+ Close();
+- } else {
+- Fail();
++
++ MOZ_ASSERT(mState == eFinished);
+ }
+
+- MOZ_ASSERT(mState == eFinished);
++ // We don't have to call Fail() if mOpened is not true since it means that
++ // either nothing has been initialized yet, so nothing to cleanup or there
++ // are pending runnables that will detect that the actor has been destroyed
++ // and call Fail().
+ }
+
+ mozilla::ipc::IPCResult
+@@ -617,6 +644,11 @@ private:
+ MOZ_ASSERT(mOpenMode == eOpenForRead);
+ MOZ_ASSERT(!mOpened);
+
++ if (NS_WARN_IF(Client::IsShuttingDownOnBackgroundThread())) {
++ Fail();
++ return IPC_OK();
++ }
++
+ switch (aResponse.type()) {
+ case OpenMetadataForReadResponse::TAsmJSCacheResult: {
+ MOZ_ASSERT(aResponse.get_AsmJSCacheResult() != JS::AsmJSCache_Success);
+@@ -682,6 +714,8 @@ private:
+ nsCOMPtr<nsIFile> mMetadataFile;
+ Metadata mMetadata;
+
++ Atomic<bool> mOperationMayProceed;
++
+ // State initialized during eWaitingToOpenCacheFileForRead
+ unsigned mModuleIndex;
+
+@@ -942,6 +976,12 @@ ParentRunnable::Run()
+ case eInitial: {
+ MOZ_ASSERT(NS_IsMainThread());
+
++ if (NS_WARN_IF(Client::IsShuttingDownOnNonBackgroundThread()) ||
++ !OperationMayProceed()) {
++ FailOnNonOwningThread();
++ return NS_OK;
++ }
++
+ rv = InitOnMainThread();
+ if (NS_FAILED(rv)) {
+ FailOnNonOwningThread();
+@@ -957,7 +997,8 @@ ParentRunnable::Run()
+ case eWaitingToFinishInit: {
+ AssertIsOnOwningThread();
+
+- if (QuotaManager::IsShuttingDown()) {
++ if (NS_WARN_IF(Client::IsShuttingDownOnBackgroundThread()) ||
++ IsActorDestroyed()) {
+ Fail();
+ return NS_OK;
+ }
+@@ -976,6 +1017,12 @@ ParentRunnable::Run()
+ case eWaitingToOpenDirectory: {
+ AssertIsOnOwningThread();
+
++ if (NS_WARN_IF(Client::IsShuttingDownOnBackgroundThread()) ||
++ IsActorDestroyed()) {
++ Fail();
++ return NS_OK;
++ }
++
+ if (NS_WARN_IF(!QuotaManager::Get())) {
+ Fail();
+ return NS_OK;
+@@ -988,6 +1035,12 @@ ParentRunnable::Run()
+ case eReadyToReadMetadata: {
+ AssertIsOnIOThread();
+
++ if (NS_WARN_IF(Client::IsShuttingDownOnNonBackgroundThread()) ||
++ !OperationMayProceed()) {
++ FailOnNonOwningThread();
++ return NS_OK;
++ }
++
+ rv = ReadMetadata();
+ if (NS_FAILED(rv)) {
+ FailOnNonOwningThread();
+@@ -1016,6 +1069,12 @@ ParentRunnable::Run()
+ AssertIsOnOwningThread();
+ MOZ_ASSERT(mOpenMode == eOpenForRead);
+
++ if (NS_WARN_IF(Client::IsShuttingDownOnBackgroundThread()) ||
++ IsActorDestroyed()) {
++ Fail();
++ return NS_OK;
++ }
++
+ mState = eWaitingToOpenCacheFileForRead;
+
+ // Metadata is now open.
+@@ -1031,6 +1090,12 @@ ParentRunnable::Run()
+ AssertIsOnIOThread();
+ MOZ_ASSERT(mOpenMode == eOpenForRead);
+
++ if (NS_WARN_IF(Client::IsShuttingDownOnNonBackgroundThread()) ||
++ !OperationMayProceed()) {
++ FailOnNonOwningThread();
++ return NS_OK;
++ }
++
+ rv = OpenCacheFileForRead();
+ if (NS_FAILED(rv)) {
+ FailOnNonOwningThread();
+@@ -1045,6 +1110,12 @@ ParentRunnable::Run()
+ case eSendingCacheFile: {
+ AssertIsOnOwningThread();
+
++ if (NS_WARN_IF(Client::IsShuttingDownOnBackgroundThread()) ||
++ IsActorDestroyed()) {
++ Fail();
++ return NS_OK;
++ }
++
+ mState = eOpened;
+
+ FileDescriptor::PlatformHandleType handle =
Copied: branches/2018Q1/www/waterfox/files/patch-bug1389561 (from r459394, head/www/waterfox/files/patch-bug1389561)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/2018Q1/www/waterfox/files/patch-bug1389561 Fri Jan 19 05:01:12 2018 (r459395, copy of r459394, head/www/waterfox/files/patch-bug1389561)
@@ -0,0 +1,758 @@
+commit 06e22a681925
+Author: Shawn Huang <shuang at mozilla.com>
+Date: Thu Oct 26 16:59:18 2017 +0800
+
+ Bug 1389561 - Part 1: Ensure origin initialized in Maintenance::DirectoryWork. r=janv
+
+ Make sure origins had been initialized in Maintenance::DirectoryWork before getting
+ QuotaObject. It's possible that DatabaseMaintenance::Run before origins initialized.
+---
+ dom/indexedDB/ActorsParent.cpp | 20 ++++++++++++++++++--
+ 1 file changed, 18 insertions(+), 2 deletions(-)
+
+diff --git dom/indexedDB/ActorsParent.cpp dom/indexedDB/ActorsParent.cpp
+index de613cc4eec0..06ffc9df84fa 100644
+--- dom/indexedDB/ActorsParent.cpp
++++ dom/indexedDB/ActorsParent.cpp
+@@ -18602,6 +18602,7 @@ Maintenance::DirectoryWork()
+ continue;
+ }
+
++ nsCString suffix;
+ nsCString group;
+ nsCString origin;
+ nsTArray<nsString> databasePaths;
+@@ -18659,17 +18660,17 @@ Maintenance::DirectoryWork()
+
+ // Found a database.
+ if (databasePaths.IsEmpty()) {
++ MOZ_ASSERT(suffix.IsEmpty());
+ MOZ_ASSERT(group.IsEmpty());
+ MOZ_ASSERT(origin.IsEmpty());
+
+ int64_t dummyTimeStamp;
+ bool dummyPersisted;
+- nsCString dummySuffix;
+ if (NS_WARN_IF(NS_FAILED(
+ quotaManager->GetDirectoryMetadata2(originDir,
+ &dummyTimeStamp,
+ &dummyPersisted,
+- dummySuffix,
++ suffix,
+ group,
+ origin)))) {
+ // Not much we can do here...
+@@ -18687,6 +18688,21 @@ Maintenance::DirectoryWork()
+ group,
+ origin,
+ Move(databasePaths)));
++
++ nsCOMPtr<nsIFile> directory;
++
++ // Idle maintenance may occur before origin is initailized.
++ // Ensure origin is initialized first. It will initialize all origins
++ // for temporary storage including IDB origins.
++ rv = quotaManager->EnsureOriginIsInitialized(persistenceType,
++ suffix,
++ group,
++ origin,
++ getter_AddRefs(directory));
++
++ if (NS_WARN_IF(NS_FAILED(rv))) {
++ return rv;
++ }
+ }
+ }
+ }
+commit a9f850009e15
+Author: Shawn Huang <shuang at mozilla.com>
+Date: Thu Nov 2 14:54:07 2017 +0800
+
+ Bug 1389561 - Part 2: Wait for idle maintenance releasing DirectoryLock when finished. r=janv
+---
+ dom/indexedDB/ActorsParent.cpp | 68 +++++++++++++++++++++++++++++++-----------
+ 1 file changed, 51 insertions(+), 17 deletions(-)
+
+diff --git dom/indexedDB/ActorsParent.cpp dom/indexedDB/ActorsParent.cpp
+index 47d621909119..cf3d32ef8fff 100644
+--- dom/indexedDB/ActorsParent.cpp
++++ dom/indexedDB/ActorsParent.cpp
+@@ -17984,11 +17984,22 @@ QuotaClient::ShutdownWorkThreads()
+
+ mShutdownRequested = true;
+
++ // Shutdown maintenance thread pool (this spins the event loop until all
++ // threads are gone). This should release any maintenance related quota
++ // objects.
+ if (mMaintenanceThreadPool) {
+ mMaintenanceThreadPool->Shutdown();
+ mMaintenanceThreadPool = nullptr;
+ }
+
++ // Let any runnables dispatched from dying maintenance threads to be
++ // processed. This should release any maintenance related directory locks.
++ if (mCurrentMaintenance) {
++ MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() {
++ return !mCurrentMaintenance;
++ }));
++ }
++
+ RefPtr<ConnectionPool> connectionPool = gConnectionPool.get();
+ if (connectionPool) {
+ connectionPool->Shutdown();
+@@ -18312,7 +18323,8 @@ Maintenance::Start()
+ AssertIsOnBackgroundThread();
+ MOZ_ASSERT(mState == State::Initial);
+
+- if (IsAborted()) {
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
++ IsAborted()) {
+ return NS_ERROR_ABORT;
+ }
+
+@@ -18336,7 +18348,8 @@ Maintenance::CreateIndexedDatabaseManager()
+ MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(mState == State::CreateIndexedDatabaseManager);
+
+- if (IsAborted()) {
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
++ IsAborted()) {
+ return NS_ERROR_ABORT;
+ }
+
+@@ -18361,7 +18374,8 @@ Maintenance::OpenDirectory()
+ MOZ_ASSERT(!mDirectoryLock);
+ MOZ_ASSERT(QuotaManager::Get());
+
+- if (IsAborted()) {
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
++ IsAborted()) {
+ return NS_ERROR_ABORT;
+ }
+
+@@ -18385,7 +18399,8 @@ Maintenance::DirectoryOpen()
+ MOZ_ASSERT(mState == State::DirectoryOpenPending);
+ MOZ_ASSERT(mDirectoryLock);
+
+- if (IsAborted()) {
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
++ IsAborted()) {
+ return NS_ERROR_ABORT;
+ }
+
+@@ -18415,7 +18430,8 @@ Maintenance::DirectoryWork()
+ // We have to find all database files that match any persistence type and any
+ // origin. We ignore anything out of the ordinary for now.
+
+- if (IsAborted()) {
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
++ IsAborted()) {
+ return NS_ERROR_ABORT;
+ }
+
+@@ -18754,6 +18770,11 @@ Maintenance::BeginDatabaseMaintenance()
+ }
+ };
+
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
++ IsAborted()) {
++ return NS_ERROR_ABORT;
++ }
++
+ RefPtr<nsThreadPool> threadPool;
+
+ for (DirectoryInfo& directoryInfo : mDirectoryInfos) {
+@@ -18940,6 +18961,11 @@ DatabaseMaintenance::PerformMaintenanceOnDatabase()
+ }
+ };
+
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
++ mMaintenance->IsAborted()) {
++ return;
++ }
++
+ nsCOMPtr<nsIFile> databaseFile = GetFileForPath(mDatabasePath);
+ MOZ_ASSERT(databaseFile);
+
+@@ -18956,10 +18982,6 @@ DatabaseMaintenance::PerformMaintenanceOnDatabase()
+
+ AutoClose autoClose(connection);
+
+- if (mMaintenance->IsAborted()) {
+- return;
+- }
+-
+ AutoProgressHandler progressHandler(mMaintenance);
+ if (NS_WARN_IF(NS_FAILED(progressHandler.Register(connection)))) {
+ return;
+@@ -18978,20 +19000,12 @@ DatabaseMaintenance::PerformMaintenanceOnDatabase()
+ return;
+ }
+
+- if (mMaintenance->IsAborted()) {
+- return;
+- }
+-
+ MaintenanceAction maintenanceAction;
+ rv = DetermineMaintenanceAction(connection, databaseFile, &maintenanceAction);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return;
+ }
+
+- if (mMaintenance->IsAborted()) {
+- return;
+- }
+-
+ switch (maintenanceAction) {
+ case MaintenanceAction::Nothing:
+ break;
+@@ -19018,6 +19032,11 @@ DatabaseMaintenance::CheckIntegrity(mozIStorageConnection* aConnection,
+ MOZ_ASSERT(aConnection);
+ MOZ_ASSERT(aOk);
+
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
++ mMaintenance->IsAborted()) {
++ return NS_ERROR_ABORT;
++ }
++
+ nsresult rv;
+
+ // First do a full integrity_check. Scope statements tightly here because
+@@ -19135,6 +19154,11 @@ DatabaseMaintenance::DetermineMaintenanceAction(
+ MOZ_ASSERT(aDatabaseFile);
+ MOZ_ASSERT(aMaintenanceAction);
+
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
++ mMaintenance->IsAborted()) {
++ return NS_ERROR_ABORT;
++ }
++
+ int32_t schemaVersion;
+ nsresult rv = aConnection->GetSchemaVersion(&schemaVersion);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+@@ -19344,6 +19368,11 @@ DatabaseMaintenance::IncrementalVacuum(mozIStorageConnection* aConnection)
+ MOZ_ASSERT(!IsOnBackgroundThread());
+ MOZ_ASSERT(aConnection);
+
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
++ mMaintenance->IsAborted()) {
++ return;
++ }
++
+ nsresult rv = aConnection->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
+ "PRAGMA incremental_vacuum;"
+ ));
+@@ -19361,6 +19390,11 @@ DatabaseMaintenance::FullVacuum(mozIStorageConnection* aConnection,
+ MOZ_ASSERT(aConnection);
+ MOZ_ASSERT(aDatabaseFile);
+
++ if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
++ mMaintenance->IsAborted()) {
++ return;
++ }
++
+ nsresult rv = aConnection->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
+ "VACUUM;"
+ ));
+commit 5d30f2130fd9
+Author: Shawn Huang <shuang at mozilla.com>
+Date: Wed Nov 1 11:14:20 2017 +0800
+
+ Bug 1389561 - Part 3: Wait for releasing all AsmJSCache parent actors in Client::ShutdownWorkThreads(). r=janv
+
+ This patch implements Client::ShutdownWorkThreads for taking care of unreleased DirectoryLock and QuotaObject objects.
+---
+ dom/asmjscache/AsmJSCache.cpp | 29 ++++++++++++++++++++++++++++-
+ 1 file changed, 28 insertions(+), 1 deletion(-)
+
+diff --git dom/asmjscache/AsmJSCache.cpp dom/asmjscache/AsmJSCache.cpp
+index 22ab3dbf0136..49a7d6974134 100644
+--- dom/asmjscache/AsmJSCache.cpp
++++ dom/asmjscache/AsmJSCache.cpp
+@@ -67,6 +67,8 @@ namespace asmjscache {
+
+ namespace {
+
++class ParentRunnable;
++
+ // Anything smaller should compile fast enough that caching will just add
+ // overhead.
+ static const size_t sMinCachedModuleLength = 10000;
+@@ -74,6 +76,10 @@ static const size_t sMinCachedModuleLength = 10000;
+ // The number of characters to hash into the Metadata::Entry::mFastHash.
+ static const unsigned sNumFastHashChars = 4096;
+
++// Track all live parent actors.
++typedef nsTArray<const ParentRunnable*> ParentActorArray;
++StaticAutoPtr<ParentActorArray> sLiveParentActors;
++
+ nsresult
+ WriteMetadataFile(nsIFile* aMetadataFile, const Metadata& aMetadata)
+ {
+@@ -802,6 +808,13 @@ ParentRunnable::FinishOnOwningThread()
+ FileDescriptorHolder::Finish();
+
+ mDirectoryLock = nullptr;
++
++ MOZ_ASSERT(sLiveParentActors);
++ sLiveParentActors->RemoveElement(this);
++
++ if (sLiveParentActors->IsEmpty()) {
++ sLiveParentActors = nullptr;
++ }
+ }
+
+ NS_IMETHODIMP
+@@ -1039,6 +1052,12 @@ AllocEntryParent(OpenMode aOpenMode,
+ RefPtr<ParentRunnable> runnable =
+ new ParentRunnable(aPrincipalInfo, aOpenMode, aWriteParams);
+
++ if (!sLiveParentActors) {
++ sLiveParentActors = new ParentActorArray();
++ }
++
++ sLiveParentActors->AppendElement(runnable);
++
+ nsresult rv = NS_DispatchToMainThread(runnable);
+ NS_ENSURE_SUCCESS(rv, nullptr);
+
+@@ -1687,7 +1706,15 @@ public:
+
+ void
+ ShutdownWorkThreads() override
+- { }
++ {
++ AssertIsOnBackgroundThread();
++
++ if (sLiveParentActors) {
++ MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() {
++ return !sLiveParentActors;
++ }));
++ }
++ }
+
+ private:
+ nsAutoRefCnt mRefCnt;
+commit 0693fefe1317
+Author: Jan Varga <jan.varga at gmail.com>
+Date: Thu Nov 2 14:54:18 2017 +0800
+
+ Bug 1389561 - Part 4: Split AsmJSCache's Client implementation into declaration and definition; r=luke
+---
+ dom/asmjscache/AsmJSCache.cpp | 271 +++++++++++++++++++++++++-----------------
+ 1 file changed, 165 insertions(+), 106 deletions(-)
+
+diff --git dom/asmjscache/AsmJSCache.cpp dom/asmjscache/AsmJSCache.cpp
+index 49a7d6974134..1ba4f66085a1 100644
+--- dom/asmjscache/AsmJSCache.cpp
++++ dom/asmjscache/AsmJSCache.cpp
+@@ -240,6 +240,60 @@ EvictEntries(nsIFile* aDirectory, const nsACString& aGroup,
+ }
+ }
+
++/*******************************************************************************
++ * Client
++ ******************************************************************************/
++
++class Client
++ : public quota::Client
++{
++public:
++ NS_INLINE_DECL_REFCOUNTING(Client, override)
++
++ Type
++ GetType() override;
++
++ nsresult
++ InitOrigin(PersistenceType aPersistenceType,
++ const nsACString& aGroup,
++ const nsACString& aOrigin,
++ const AtomicBool& aCanceled,
++ UsageInfo* aUsageInfo) override;
++
++ nsresult
++ GetUsageForOrigin(PersistenceType aPersistenceType,
++ const nsACString& aGroup,
++ const nsACString& aOrigin,
++ const AtomicBool& aCanceled,
++ UsageInfo* aUsageInfo) override;
++
++ void
++ OnOriginClearCompleted(PersistenceType aPersistenceType,
++ const nsACString& aOrigin)
++ override;
++
++ void
++ ReleaseIOThreadObjects() override;
++
++ void
++ AbortOperations(const nsACString& aOrigin) override;
++
++ void
++ AbortOperationsForProcess(ContentParentId aContentParentId) override;
++
++ void
++ StartIdleMaintenance() override;
++
++ void
++ StopIdleMaintenance() override;
++
++ void
++ ShutdownWorkThreads() override;
++
++private:
++ ~Client() override = default;
++};
++
+ // FileDescriptorHolder owns a file descriptor and its memory mapping.
+ // FileDescriptorHolder is derived by two runnable classes (that is,
+ // (Parent|Child)Runnable.
+@@ -1593,136 +1647,141 @@ CloseEntryForWrite(size_t aSize,
+ }
+ }
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-ports-all
mailing list