From 5cad29e95879a5a08cb1a8dabfff8eda17e55763 Mon Sep 17 00:00:00 2001 From: Armin Weatherwax Date: Tue, 2 Mar 2010 14:55:47 +0100 Subject: Aleric Inglewood: SNOW-196 Special case for TextureFetch race condition check. Where the current UUID was just removed from mRequestMap, thus avoiding to the need for the problematic lock completely. The case that we add something to mNetworkQueue while it was just removed from mRequestMap is corrected by LLTextureFetch::sendRequestListToSimulators anyway. --- linden/indra/newview/lltexturefetch.cpp | 42 ++++++++++----------------------- 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'linden/indra/newview') diff --git a/linden/indra/newview/lltexturefetch.cpp b/linden/indra/newview/lltexturefetch.cpp index 3a5665c..62b4c8b 100644 --- a/linden/indra/newview/lltexturefetch.cpp +++ b/linden/indra/newview/lltexturefetch.cpp @@ -744,26 +744,17 @@ bool LLTextureFetchWorker::doWork(S32 param) } else if (mSentRequest == UNSENT) { - if(mFetcher->mQueueMutex.tryLock()) - { - // Add this to the network queue and sit here. - // LLTextureFetch::update() will send off a request which will change our state - mRequestedSize = mDesiredSize; - mRequestedDiscard = mDesiredDiscard; - mSentRequest = QUEUED; - mFetcher->addToNetworkQueue(this); - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); - mFetcher->mQueueMutex.unlock(); - } + // Add this to the network queue and sit here. + // LLTextureFetch::update() will send off a request which will change our state + mRequestedSize = mDesiredSize; + mRequestedDiscard = mDesiredDiscard; + mSentRequest = QUEUED; + mFetcher->addToNetworkQueue(this); + setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); return false; } else { - // Shouldn't need to do anything here - //llassert_always(mFetcher->mNetworkQueue.find(mID) != mFetcher->mNetworkQueue.end()); - // Make certain this is in the network queue - //mFetcher->addToNetworkQueue(this); - //setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); return false; } } @@ -1473,23 +1464,12 @@ void LLTextureFetch::deleteRequest(const LLUUID& id, bool cancel) } } -// Need to hold mQueueMutex when entering this function SNOW-196 -// Snowglobe ToDo fix holding mQueueMutex over the entire function, we only need -// it for the mRequestMap access // protected void LLTextureFetch::addToNetworkQueue(LLTextureFetchWorker* worker) { - bool is_worker_in_request_map = (mRequestMap.find(worker->mID) != mRequestMap.end()); - LLMutexLock lock(&mNetworkQueueMutex); - if (is_worker_in_request_map) - { - // only add to the queue if in the request map - // i.e. a delete has not been requested - mNetworkQueue.insert(worker->mID); - } - for (cancel_queue_t::iterator iter1 = mCancelQueue.begin(); - iter1 != mCancelQueue.end(); ++iter1) + mNetworkQueue.insert(worker->mID); + for (cancel_queue_t::iterator iter1 = mCancelQueue.begin(); iter1 != mCancelQueue.end(); ++iter1) { iter1->second.erase(worker->mID); } @@ -1715,8 +1695,10 @@ void LLTextureFetch::sendRequestListToSimulators() LLTextureFetchWorker* req = getWorker(*curiter); if (!req) { + // This happens when a request was removed from mRequestMap in a race + // with adding it to mNetworkQueue by doWork (see SNOW-196). mNetworkQueue.erase(curiter); - continue; // paranoia + continue; } llassert(req->mState == LLTextureFetchWorker::LOAD_FROM_NETWORK || LLTextureFetchWorker::LOAD_FROM_SIMULATOR); if ((req->mState != LLTextureFetchWorker::LOAD_FROM_NETWORK) && -- cgit v1.1