From c9f5bc7cae793b6965ceb9490243b4c52017c254 Mon Sep 17 00:00:00 2001
From: Monty Brandenberg <monty@lindenlab.com>
Date: Tue, 17 Jul 2012 11:24:52 -0400
Subject: [PATCH] SH-3189 Improve naive data structures Move
 releaseHttpWaiters() to commonUpdate from doWork. More appropriate home for
 it.  Have deleteOK() defer deletion of anything in WAIT_HTTP_RESOURCE2 state
 to keep pointers valid for the releaseHttpWaiters() method.  It will then
 transition canceled operations to SEND_HTTP_REQ where they can be deleted.

---
 indra/newview/lltexturefetch.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 225ea46558c..51d57ccf689 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -1064,9 +1064,6 @@ bool LLTextureFetchWorker::doWork(S32 param)
 	static const LLCore::HttpStatus http_service_unavail(HTTP_SERVICE_UNAVAILABLE);		// 503
 	static const LLCore::HttpStatus http_not_sat(HTTP_REQUESTED_RANGE_NOT_SATISFIABLE);	// 416;
 	
-	// Release waiters while we aren't holding the Mw lock.
-	mFetcher->releaseHttpWaiters();
-	
 	LLMutexLock lock(&mWorkMutex);										// +Mw
 
 	if ((mFetcher->isQuitting() || getFlags(LLWorkerClass::WCF_DELETE_REQUESTED)))
@@ -1927,6 +1924,14 @@ bool LLTextureFetchWorker::deleteOK()
 		// and will dereference it to do notification.
 		delete_ok = false;
 	}
+
+	if (WAIT_HTTP_RESOURCE2 == mState)
+	{
+		// Don't delete the worker out from under the
+		// releaseHttpWaiters() method.  Keep the pointers
+		// valid, clean up after transition.
+		delete_ok = false;
+	}
 	
 	// Allow any pending reads or writes to complete
 	if (mCacheReadHandle != LLTextureCache::nullHandle())
@@ -2737,6 +2742,9 @@ bool LLTextureFetch::runCondition()
 // Threads:  Ttf
 void LLTextureFetch::commonUpdate()
 {
+	// Release waiters
+	releaseHttpWaiters();
+	
 	// Run a cross-thread command, if any.
 	cmdDoWork();
 	
-- 
GitLab