From abe0eb2ba72d644c3e4b717b391ca9cbcead162c Mon Sep 17 00:00:00 2001
From: Steve Bennetts <steve@lindenlab.com>
Date: Thu, 17 Dec 2009 16:19:00 -0800
Subject: [PATCH] HTTP Texture changes: * Fixed bug in llqueuedthread.cpp
 causing unnecesssary sleeeping * Fixed an issue that was preventing retries
 on 503 errors * Added number of pending creates to Texture View * Increased
 time allocated for texture creates

---
 indra/llcommon/llqueuedthread.cpp     |  4 ++--
 indra/newview/lltexturefetch.cpp      | 30 +++++++++++++--------------
 indra/newview/lltextureview.cpp       |  5 +++--
 indra/newview/llviewertexturelist.cpp |  2 +-
 4 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp
index eacbbb3ee0b..06ceeb2bc3c 100644
--- a/indra/llcommon/llqueuedthread.cpp
+++ b/indra/llcommon/llqueuedthread.cpp
@@ -437,6 +437,7 @@ S32 LLQueuedThread::processNextRequest()
 	if (req)
 	{
 		// process request
+		U32 start_priority = req->getPriority();
 		bool complete = req->processRequest();
 
 		if (complete)
@@ -457,9 +458,8 @@ S32 LLQueuedThread::processNextRequest()
 			lockData();
 			req->setStatus(STATUS_QUEUED);
 			mRequestQueue.insert(req);
-			U32 priority = req->getPriority();
 			unlockData();
-			if (priority < PRIORITY_NORMAL)
+			if (mThreaded && start_priority <= PRIORITY_LOW)
 			{
 				ms_sleep(1); // sleep the thread a little
 			}
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 9f69ed3964f..83e0b539606 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -448,6 +448,7 @@ LLTextureFetchWorker::~LLTextureFetchWorker()
 	mFormattedImage = NULL;
 	clearPackets();
 	unlockWorkMutex();
+	mFetcher->removeFromHTTPQueue(mID);
 }
 
 void LLTextureFetchWorker::clearPackets()
@@ -821,6 +822,13 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			if (mFormattedImage.notNull())
 			{
 				cur_size = mFormattedImage->getDataSize(); // amount of data we already have
+				if (mFormattedImage->getDiscardLevel() == 0)
+				{
+					// We already have all the data, just decode it
+					mLoadedDiscard = mFormattedImage->getDiscardLevel();
+					mState = DECODE_IMAGE;
+					return false;
+				}
 			}
 			mRequestedSize = mDesiredSize;
 			mRequestedDiscard = mDesiredDiscard;
@@ -871,26 +879,16 @@ bool LLTextureFetchWorker::doWork(S32 param)
  				llinfos << "HTTP GET failed for: " << mUrl
 						<< " Status: " << mGetStatus << " Reason: '" << mGetReason << "'"
 						<< " Attempt:" << mHTTPFailCount+1 << "/" << max_attempts << llendl;
-				if (cur_size == 0)
+				++mHTTPFailCount;
+				if (mHTTPFailCount >= max_attempts)
 				{
-					++mHTTPFailCount;
-					if (mHTTPFailCount >= max_attempts)
-					{
-						resetFormattedData();
-						return true; // failed
-					}
-					else
-					{
-						mState = SEND_HTTP_REQ;
-						return false; // retry
-					}
+					resetFormattedData();
+					return true; // failed
 				}
 				else
 				{
-					// mFormattedImage gauranteed to not be NULL since cur_size != 0
-					mLoadedDiscard = mFormattedImage->getDiscardLevel();
-					mState = DECODE_IMAGE;
-					return false; // use what we have
+					mState = SEND_HTTP_REQ;
+					return false; // retry
 				}
 			}
 			
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index b6e20608eb4..9573b884eb9 100644
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -494,7 +494,7 @@ void LLGLTexMemBar::draw()
 #endif
 	//----------------------------------------------------------------------------
 
-	text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d RAW:%d HTP:%d",
+	text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d RAW:%d HTP:%d CRE:%d",
 					gTextureList.getNumImages(),
 					LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(),
 					LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount, 
@@ -502,7 +502,8 @@ void LLGLTexMemBar::draw()
 					LLLFSThread::sLocal->getPending(),
 					LLAppViewer::getImageDecodeThread()->getPending(), 
 					LLImageRaw::sRawImageCount,
-					LLAppViewer::getTextureFetch()->getNumHTTPRequests());
+					LLAppViewer::getTextureFetch()->getNumHTTPRequests(),
+					gTextureList.mCreateTextureList.size());
 
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, h_offset + line_height*2,
 									 text_color, LLFontGL::LEFT, LLFontGL::TOP);
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index e066546bd81..8252b7df003 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -588,7 +588,7 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	F32 total_max_time = max_time;
 	max_time -= updateImagesFetchTextures(max_time);
 	
-	max_time = llmax(max_time, total_max_time*.25f); // at least 25% of max_time
+	max_time = llmax(max_time, total_max_time*.50f); // at least 50% of max_time
 	max_time -= updateImagesCreateTextures(max_time);
 	
 	if (!mDirtyTextureList.empty())
-- 
GitLab