summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-04-08 21:54:05 +0200
committerMoonchild <moonchild@palemoon.org>2022-04-09 09:58:39 +0200
commit1bb7d136671265eb19b9bfd1ac2d783b1ef2397e (patch)
treeae1a6ac5f9c3ee1d789584d8875dc4ab54c2bb89
parent240b39f4498a8655344e833408c1c7cb49c3c48e (diff)
downloaduxp-1bb7d136671265eb19b9bfd1ac2d783b1ef2397e.tar.gz
[XPCOM] xpcom/threads misc cleanup
-rw-r--r--xpcom/threads/LazyIdleThread.cpp13
-rw-r--r--xpcom/threads/LazyIdleThread.h3
-rw-r--r--xpcom/threads/nsProcessCommon.cpp19
3 files changed, 24 insertions, 11 deletions
diff --git a/xpcom/threads/LazyIdleThread.cpp b/xpcom/threads/LazyIdleThread.cpp
index d74f515e87..c5c7a5f192 100644
--- a/xpcom/threads/LazyIdleThread.cpp
+++ b/xpcom/threads/LazyIdleThread.cpp
@@ -137,10 +137,15 @@ LazyIdleThread::EnsureThread()
return NS_OK;
}
- MOZ_ASSERT(!mPendingEventCount, "Shouldn't have events yet!");
- MOZ_ASSERT(!mIdleNotificationCount, "Shouldn't have idle events yet!");
- MOZ_ASSERT(!mIdleTimer, "Should have killed this long ago!");
- MOZ_ASSERT(!mThreadIsShuttingDown, "Should have cleared that!");
+#ifdef DEBUG
+ { // Lock scope
+ MutexAutoLock lock(mMutex);
+ MOZ_ASSERT(!mPendingEventCount, "Shouldn't have events yet!");
+ MOZ_ASSERT(!mIdleNotificationCount, "Shouldn't have idle events yet!");
+ MOZ_ASSERT(!mIdleTimer, "Should have killed this long ago!");
+ MOZ_ASSERT(!mThreadIsShuttingDown, "Should have cleared that!");
+ }
+#endif
nsresult rv;
diff --git a/xpcom/threads/LazyIdleThread.h b/xpcom/threads/LazyIdleThread.h
index 460971c7a8..9d437171a7 100644
--- a/xpcom/threads/LazyIdleThread.h
+++ b/xpcom/threads/LazyIdleThread.h
@@ -152,9 +152,10 @@ private:
nsCOMPtr<nsIThread> mThread;
/**
- * Protected by mMutex. Created when mThread has no pending events and fired
+ * Created when mThread has no pending events and fired
* at mOwningThread. Any thread that dispatches to mThread will take ownership
* of the timer and fire a separate cancel event to the owning thread.
+ * Only accessed from the owning thread.
*/
nsCOMPtr<nsITimer> mIdleTimer;
diff --git a/xpcom/threads/nsProcessCommon.cpp b/xpcom/threads/nsProcessCommon.cpp
index e815ec9ea4..033c358d8d 100644
--- a/xpcom/threads/nsProcessCommon.cpp
+++ b/xpcom/threads/nsProcessCommon.cpp
@@ -280,10 +280,13 @@ nsProcess::ProcessComplete()
}
const char* topic;
- if (mExitValue < 0) {
- topic = "process-failed";
- } else {
- topic = "process-finished";
+ { // Lock scope
+ MutextAutoLock lock(mLock);
+ if (mExitValue < 0) {
+ topic = "process-failed";
+ } else {
+ topic = "process-finished";
+ }
}
mPid = -1;
@@ -412,8 +415,11 @@ nsProcess::RunProcess(bool aBlocking, char** aMyArgv, nsIObserver* aObserver,
}
}
- mExitValue = -1;
- mPid = -1;
+ {
+ MutexAutoLock lock(mLock);
+ mExitValue = -1;
+ mPid = -1;
+ }
#if defined(PROCESSMODEL_WINAPI)
BOOL retVal;
@@ -477,6 +483,7 @@ nsProcess::RunProcess(bool aBlocking, char** aMyArgv, nsIObserver* aObserver,
mBlocking = aBlocking;
if (aBlocking) {
Monitor(this);
+ MutexAutoLock lock(mLock);
if (mExitValue < 0) {
return NS_ERROR_FILE_EXECUTION_FAILED;
}