From e0efbd7d262b79585117c18e320d61fed4d79d5d Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 10 Jan 2020 00:09:35 -0600 Subject: [PATCH] Fix two race conditions in meshrepo. --- indra/newview/llmeshrepository.cpp | 24 ++++++++++++++++++++++-- indra/newview/llmeshrepository.h | 2 ++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 5c26cc4e7..a21a500aa 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -569,6 +569,8 @@ LLMeshRepoThread::LLMeshRepoThread() mMutex = new LLMutex(); mHeaderMutex = new LLMutex(); mSignal = new LLCondition(); + mSkinInfoQMutex = new LLMutex(); + mDecompositionQMutex = new LLMutex(); } LLMeshRepoThread::~LLMeshRepoThread() @@ -579,6 +581,10 @@ LLMeshRepoThread::~LLMeshRepoThread() mHeaderMutex = NULL; delete mSignal; mSignal = NULL; + delete mSkinInfoQMutex; + mSkinInfoQMutex = NULL; + delete mDecompositionQMutex; + mDecompositionQMutex = NULL; } bool LLMeshRepoThread::HeaderRequest::fetch(U32& count) @@ -1167,7 +1173,9 @@ bool LLMeshRepoThread::skinInfoReceived(const LLUUID& mesh_id, U8* data, S32 dat info.mMeshID = mesh_id; //LL_INFOS() <<"info pelvis offset"<lock(); mSkinInfoQ.push(info); + mSkinInfoQMutex->unlock(); } return true; @@ -1193,7 +1201,9 @@ bool LLMeshRepoThread::decompositionReceived(const LLUUID& mesh_id, U8* data, S3 { LLModel::Decomposition* d = new LLModel::Decomposition(decomp); d->mMeshID = mesh_id; + mDecompositionQMutex->lock(); mDecompositionQ.push(d); + mDecompositionQMutex->unlock(); } return true; @@ -1252,7 +1262,9 @@ bool LLMeshRepoThread::physicsShapeReceived(const LLUUID& mesh_id, U8* data, S32 } } + mDecompositionQMutex->lock(); mDecompositionQ.push(d); + mDecompositionQMutex->unlock(); return true; } @@ -1862,14 +1874,22 @@ void LLMeshRepoThread::notifyLoadedMeshes() while (!mSkinInfoQ.empty()) { - gMeshRepo.notifySkinInfoReceived(mSkinInfoQ.front()); + mSkinInfoQMutex->lock(); + auto req = mSkinInfoQ.front(); mSkinInfoQ.pop(); + mSkinInfoQMutex->unlock(); + + gMeshRepo.notifySkinInfoReceived(req); } while (!mDecompositionQ.empty()) { - gMeshRepo.notifyDecompositionReceived(mDecompositionQ.front()); + mDecompositionQMutex->lock(); + auto req = mDecompositionQ.front(); mDecompositionQ.pop(); + mDecompositionQMutex->unlock(); + + gMeshRepo.notifyDecompositionReceived(req); } } diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 6931cd3df..c73511dcd 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -265,6 +265,7 @@ public: //queue of completed skin info requests std::queue mSkinInfoQ; + LLMutex* mSkinInfoQMutex; //set of requested decompositions uuid_set_t mDecompositionRequests; @@ -274,6 +275,7 @@ public: //queue of completed Decomposition info requests std::queue mDecompositionQ; + LLMutex* mDecompositionQMutex; //queue of requested headers std::deque, F32> > mHeaderReqQ;