diff options
author | Moonchild <moonchild@palemoon.org> | 2022-04-09 00:33:41 +0200 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-04-09 00:33:41 +0200 |
commit | 3d43617bc116357e2cc840599da5494f8e9947f3 (patch) | |
tree | 49c9c7b8450daeaac8475d48ecbf5c1d017ce66f | |
parent | ac9fdbf123c0ea1aa162f998e80442a65506382b (diff) | |
download | uxp-3d43617bc116357e2cc840599da5494f8e9947f3.tar.gz |
[xpcom] xpcom Threadpool cleanup
Make sure thread locks are in place to guard accesses.
-rw-r--r-- | xpcom/threads/nsThreadPool.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/xpcom/threads/nsThreadPool.cpp b/xpcom/threads/nsThreadPool.cpp index ec8f326719..2d852809ab 100644 --- a/xpcom/threads/nsThreadPool.cpp +++ b/xpcom/threads/nsThreadPool.cpp @@ -155,8 +155,6 @@ nsThreadPool::Run() { mThreadNaming.SetThreadPoolName(mName); - LOG(("THRD-P(%p) enter %s\n", this, mName.BeginReading())); - nsCOMPtr<nsIThread> current; nsThreadManager::get().GetCurrentThread(getter_AddRefs(current)); @@ -169,6 +167,7 @@ nsThreadPool::Run() { MutexAutoLock lock(mMutex); listener = mListener; + LOG(("THRD-P(%p) enter %s\n", this, mName.BeginReading())); } if (listener) { @@ -223,7 +222,12 @@ nsThreadPool::Run() } } if (event) { - LOG(("THRD-P(%p) %s running [%p]\n", this, mName.BeginReading(), event.get())); +#ifdef DEBUG + { + MutexAutoLock lock(mMutex); + LOG(("THRD-P(%p) %s running [%p]\n", this, mName.BeginReading(), event.get())); + } +#endif event->Run(); } } while (!exitThread); @@ -335,6 +339,7 @@ nsThreadPool::Shutdown() NS_IMETHODIMP nsThreadPool::GetThreadLimit(uint32_t* aValue) { + MutexAutoLock lock(mMutex); *aValue = mThreadLimit; return NS_OK; } @@ -358,6 +363,7 @@ nsThreadPool::SetThreadLimit(uint32_t aValue) NS_IMETHODIMP nsThreadPool::GetIdleThreadLimit(uint32_t* aValue) { + MutexAutoLock lock(mMutex); *aValue = mIdleThreadLimit; return NS_OK; } @@ -382,6 +388,7 @@ nsThreadPool::SetIdleThreadLimit(uint32_t aValue) NS_IMETHODIMP nsThreadPool::GetIdleThreadTimeout(uint32_t* aValue) { + MutexAutoLock lock(mMutex); *aValue = mIdleThreadTimeout; return NS_OK; } @@ -438,11 +445,9 @@ nsThreadPool::SetListener(nsIThreadPoolListener* aListener) NS_IMETHODIMP nsThreadPool::SetName(const nsACString& aName) { - { - MutexAutoLock lock(mMutex); - if (mThreads.Count()) { - return NS_ERROR_NOT_AVAILABLE; - } + MutexAutoLock lock(mMutex); + if (mThreads.Count()) { + return NS_ERROR_NOT_AVAILABLE; } mName = aName; |