From e3db003cbff0faa44d29e35139601b9778acfbca Mon Sep 17 00:00:00 2001
From: Monty Brandenberg <monty@lindenlab.com>
Date: Wed, 8 May 2013 13:48:14 -0400
Subject: [PATCH] SH-4139 Convert http downloaders and responders to llcorehttp
 patterns Conversion was mostly trivial.  Did some refactoring in the
 conversion of Responders to Handlers which eliminated 5X code replication. 
 More will be done especially as this is extended to deal with the various
 possible combinations of 200/206/416 status for ranged gets.  There are a lot
 of thread races in the existing code, that is going to need some real
 attention.  And the scheduling/liveness logic in the thread management
 bounces around from thread to thread wasting a lot of time and using
 expensive synchronization.  Much can be done here.  But the result is that
 the 8 connections in the Mesh corehttp class now perform as did the 32
 connections of the original.  And that 32 actually looks like it could bleed
 to over 64.  So, progress...

---
 indra/newview/llmeshrepository.cpp | 54 ++++--------------------------
 1 file changed, 6 insertions(+), 48 deletions(-)

diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 2d4692be5b6..7a7cc72711e 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -756,25 +756,21 @@ void LLMeshRepoThread::run()
 		if (! mHttpRequestSet.empty())
 		{
 			mHttpRequest->update(0L);
-			ms_sleep(100);
-		}
-		else
-		{
-			mWaiting = true;
-			mSignal->wait();
-			mWaiting = false;
 		}
+
+		mWaiting = true;
+		mSignal->wait();
+		mWaiting = false;
 		
 		if (! LLApp::isQuitting())
 		{
 			static U32 count = 0;
-
 			static F32 last_hundred = gFrameTimeSeconds;
 
 			if (gFrameTimeSeconds - last_hundred > 1.f)
 			{ //a second has gone by, clear count
 				last_hundred = gFrameTimeSeconds;
-				count = 0;	
+				count = 0;
 			}
 
 			// NOTE: throttling intentionally favors LOD requests over header requests
@@ -1015,10 +1011,6 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id)
 			std::string http_url = constructUrl(mesh_id);
 			if (!http_url.empty())
 			{
-#if 0
-				ret = mCurlRequest->getByteRange(http_url, headers, offset, size,
-												 new LLMeshSkinInfoResponder(mesh_id, offset, size));
-#else
 				LLMeshSkinInfoHandler * handler = new LLMeshSkinInfoHandler(mesh_id, offset, size);
 				// LL_WARNS("Mesh") << "MESH:  Issuing Skin Info Request" << LL_ENDL;
 				LLCore::HttpHandle handle = mHttpRequest->requestGetByteRange(mHttpPolicyClass,
@@ -1040,10 +1032,6 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id)
 				{
 					handler->mHttpHandle = handle;
 					mHttpRequestSet.insert(handler);
-				}
-#endif
-				if (ret)
-				{
 					LLMeshRepository::sHTTPRequestCount++;
 				}
 			}
@@ -1122,10 +1110,6 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
 			std::string http_url = constructUrl(mesh_id);
 			if (!http_url.empty())
 			{
-#if 0
-				ret = mCurlRequest->getByteRange(http_url, headers, offset, size,
-												 new LLMeshDecompositionResponder(mesh_id, offset, size));
-#else
 				LLMeshDecompositionHandler * handler = new LLMeshDecompositionHandler(mesh_id, offset, size);
 				// LL_WARNS("Mesh") << "MESH:  Issuing Decomp Request" << LL_ENDL;
 				LLCore::HttpHandle handle = mHttpRequest->requestGetByteRange(mHttpPolicyClass,
@@ -1147,10 +1131,6 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
 				{
 					handler->mHttpHandle = handle;
 					mHttpRequestSet.insert(handler);
-				}
-#endif
-				if (ret)
-				{
 					LLMeshRepository::sHTTPRequestCount++;
 				}
 			}
@@ -1228,10 +1208,6 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id)
 			std::string http_url = constructUrl(mesh_id);
 			if (!http_url.empty())
 			{
-#if 0
-				ret = mCurlRequest->getByteRange(http_url, headers, offset, size,
-												 new LLMeshPhysicsShapeResponder(mesh_id, offset, size));
-#else
 				LLMeshPhysicsShapeHandler * handler = new LLMeshPhysicsShapeHandler(mesh_id, offset, size);
 				// LL_WARNS("Mesh") << "MESH:  Issuing Physics Shape Request" << LL_ENDL;
 				LLCore::HttpHandle handle = mHttpRequest->requestGetByteRange(mHttpPolicyClass,
@@ -1253,10 +1229,6 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id)
 				{
 					handler->mHttpHandle = handle;
 					mHttpRequestSet.insert(handler);
-				}
-#endif
-				if (ret)
-				{
 					LLMeshRepository::sHTTPRequestCount++;
 				}
 			}
@@ -1338,9 +1310,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, U32& c
 		//grab first 4KB if we're going to bother with a fetch.  Cache will prevent future fetches if a full mesh fits
 		//within the first 4KB
 		//NOTE -- this will break of headers ever exceed 4KB		
-#if 0
-		retval = mCurlRequest->getByteRange(http_url, headers, 0, MESH_HEADER_SIZE, new LLMeshHeaderResponder(mesh_params));
-#else
+
 		LLMeshHeaderHandler * handler = new LLMeshHeaderHandler(mesh_params);
 		// LL_WARNS("Mesh") << "MESH:  Issuing Request" << LL_ENDL;
 		LLCore::HttpHandle handle = mHttpRequest->requestGetByteRange(mHttpPolicyClass,
@@ -1362,10 +1332,6 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, U32& c
 		{
 			handler->mHttpHandle = handle;
 			mHttpRequestSet.insert(handler);
-		}
-#endif		
-		if(retval)
-		{
 			LLMeshRepository::sHTTPRequestCount++;
 		}
 		count++;
@@ -1435,10 +1401,6 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod,
 			std::string http_url = constructUrl(mesh_id);
 			if (!http_url.empty())
 			{
-#if 0
-				retval = mCurlRequest->getByteRange(constructUrl(mesh_id), headers, offset, size,
-										   new LLMeshLODResponder(mesh_params, lod, offset, size));
-#else
 				LLMeshLODHandler * handler = new LLMeshLODHandler(mesh_params, lod, offset, size);
 				// LL_WARNS("Mesh") << "MESH:  Issuing LOD Request" << LL_ENDL;
 				LLCore::HttpHandle handle = mHttpRequest->requestGetByteRange(mHttpPolicyClass,
@@ -1460,10 +1422,6 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod,
 				{
 					handler->mHttpHandle = handle;
 					mHttpRequestSet.insert(handler);
-				}
-#endif
-				if(retval)
-				{
 					LLMeshRepository::sHTTPRequestCount++;
 				}
 				count++;
-- 
GitLab