summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2024-01-07 14:44:52 +0100
committerGuru <alexandrgproductengine@lindenlab.com>2024-01-07 18:59:43 +0100
commite4a1feb83079965fbebd356aa694adf100fb7ee3 (patch)
treee4f188cd36fe5afa0fd36971982bef7fe1388414 /indra
parentf62b8591a29481ce882b1e50246f848475d3fb6a (diff)
SL-20743 Use LLMutex in LLImageBase for internal data thread-safety (update)
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llmutex.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp
index f56c2d08a6..973ecbc87b 100644
--- a/indra/llcommon/llmutex.cpp
+++ b/indra/llcommon/llmutex.cpp
@@ -196,9 +196,18 @@ void LLSharedMutex::lockExclusive()
LLThread::id_t current_thread = LLThread::currentID();
mLockMutex.lock();
- if (mLockingThreads.size() == 1 && mLockingThreads.begin()->first == current_thread)
+ iterator it = mLockingThreads.find(current_thread);
+ if (it != mLockingThreads.end())
{
- mLockingThreads.begin()->second++;
+ if (mIsShared)
+ {
+ // The mutex is already locked in the current thread
+ // but this lock is SHARED (not EXCLISIVE)
+ // We can't lock it again, the lock stays shared
+ // This can lead to a collision (theoretically)
+ llassert_always(!"The current thread is already locked SHARED and can't be locked EXCLUSIVE");
+ }
+ it->second++;
}
else
{