From 2e8e40cf7974a4ab6ca13d264104dbb8b80419b7 Mon Sep 17 00:00:00 2001
From: Monty Brandenberg <monty@lindenlab.com>
Date: Wed, 11 Sep 2013 18:00:55 -0400
Subject: [PATCH] SH-4489 New debug/dev settings for control over new mesh
 behavior Added 'MeshUseGetMesh1' and 'MeshUseHttpRetryAfter' debug settings
 to control mesh transport behavior.  First forces the use of the legacy mesh
 fetch style with high concurrency and connection churn. The second, on by
 default, honors Retry-After values if they are reasonable.  If off or
 unreasonable, internal delay times are used.

---
 indra/llcorehttp/httpoptions.h          |  2 +-
 indra/newview/app_settings/settings.xml | 22 ++++++++++++++++++++++
 indra/newview/llmeshrepository.cpp      |  8 +++++++-
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h
index f49a3555aa9..4ab5ff18c43 100755
--- a/indra/llcorehttp/httpoptions.h
+++ b/indra/llcorehttp/httpoptions.h
@@ -103,7 +103,7 @@ class HttpOptions : public LLCoreInt::RefCounted
 			return mRetries;
 		}
 
-	// Default:  false
+	// Default:  true
 	void				setUseRetryAfter(bool use_retry);
 	bool				getUseRetryAfter() const
 		{
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 47a2f402af8..9948f9974a3 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9979,6 +9979,28 @@
     <string>U32</string>
     <key>Value</key>
     <integer>32</integer>
+  </map>
+  <key>MeshUseHttpRetryAfter</key>
+  <map>
+    <key>Comment</key>
+    <string>If TRUE, use Retry-After response headers when rescheduling a mesh request that fails with an HTTP 503 status.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <boolean>1</boolean>
+  </map>
+  <key>MeshUseGetMesh1</key>
+  <map>
+    <key>Comment</key>
+    <string>If TRUE, use the legacy GetMesh capability for mesh download requests.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <boolean>0</boolean>
   </map>
    <key>RunMultipleThreads</key>
     <map>
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index f6a85ac94f0..507797a85d2 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -743,8 +743,10 @@ LLMeshRepoThread::LLMeshRepoThread()
 	mHttpRequest = new LLCore::HttpRequest;
 	mHttpOptions = new LLCore::HttpOptions;
 	mHttpOptions->setTransferTimeout(SMALL_MESH_XFER_TIMEOUT);
+	mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter"));
 	mHttpLargeOptions = new LLCore::HttpOptions;
 	mHttpLargeOptions->setTransferTimeout(LARGE_MESH_XFER_TIMEOUT);
+	mHttpLargeOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter"));
 	mHttpHeaders = new LLCore::HttpHeaders;
 	mHttpHeaders->append("Accept", "application/vnd.ll.mesh");
 	mHttpPolicyClass = LLAppViewer::instance()->getAppCoreHttp().getPolicy(LLAppCoreHttp::AP_MESH2);
@@ -1828,6 +1830,7 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data,
 	mHttpRequest = new LLCore::HttpRequest;
 	mHttpOptions = new LLCore::HttpOptions;
 	mHttpOptions->setTransferTimeout(mMeshUploadTimeOut);
+	mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter"));
 	mHttpHeaders = new LLCore::HttpHeaders;
 	mHttpHeaders->append("Content-Type", "application/llsd+xml");
 	mHttpPolicyClass = LLAppViewer::instance()->getAppCoreHttp().getPolicy(LLAppCoreHttp::AP_UPLOADS);
@@ -3211,13 +3214,16 @@ void LLMeshRepository::notifyLoadedMeshes()
 			
 			if (gAgent.getRegion()->getName() != region_name && gAgent.getRegion()->capabilitiesReceived())
 			{
+				const bool use_v1(gSavedSettings.getBOOL("MeshUseGetMesh1"));
+
 				region_name = gAgent.getRegion()->getName();
 				mGetMeshCapability = gAgent.getRegion()->getCapability("GetMesh");
 				mGetMesh2Capability = gAgent.getRegion()->getCapability("GetMesh2");
-				mGetMeshVersion = mGetMesh2Capability.empty() ? 1 : 2;
+				mGetMeshVersion = (mGetMesh2Capability.empty() || use_v1) ? 1 : 2;
 				LL_DEBUGS(LOG_MESH) << "Retrieving caps for region '" << region_name
 									<< "', GetMesh2:  " << mGetMesh2Capability
 									<< ", GetMesh:  " << mGetMeshCapability
+									<< ", using version:  " << mGetMeshVersion
 									<< LL_ENDL;
 			}
 		}
-- 
GitLab