From 87176418a2acaaecab8d0e8b48a721fb7ca36dec Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sun, 23 Jun 2013 18:05:23 +0200 Subject: [PATCH] Change CurlConcurrentConnectionsPerService to U16 and clamp it between 1 and 32. Also fixes a bug where going from 1 to 2 would not update AIPerService::mConcurrectConnections correctly. --- indra/llmessage/aicurlperservice.cpp | 7 ++++--- indra/llmessage/aicurlperservice.h | 2 +- indra/llmessage/aicurlthread.cpp | 19 ++++++++++++++----- .../app_settings/settings_crash_behavior.xml | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/indra/llmessage/aicurlperservice.cpp b/indra/llmessage/aicurlperservice.cpp index 4c503e517..78a4761e0 100644 --- a/indra/llmessage/aicurlperservice.cpp +++ b/indra/llmessage/aicurlperservice.cpp @@ -49,7 +49,7 @@ AIThreadSafeSimpleDC AIPerService::sTotalQueued; namespace AICurlPrivate { // Cached value of CurlConcurrentConnectionsPerService. -U32 CurlConcurrentConnectionsPerService; +U16 CurlConcurrentConnectionsPerService; // Friend functions of RefCountedThreadSafePerService @@ -473,8 +473,9 @@ void AIPerService::adjust_concurrent_connections(int increment) for (AIPerService::iterator iter = instance_map_w->begin(); iter != instance_map_w->end(); ++iter) { PerService_wat per_service_w(*iter->second); - U32 old_concurrent_connections = per_service_w->mConcurrectConnections; - per_service_w->mConcurrectConnections = llclamp(old_concurrent_connections + increment, (U32)1, CurlConcurrentConnectionsPerService); + U16 old_concurrent_connections = per_service_w->mConcurrectConnections; + int new_concurrent_connections = llclamp(old_concurrent_connections + increment, 1, (int)CurlConcurrentConnectionsPerService); + per_service_w->mConcurrectConnections = (U16)new_concurrent_connections; increment = per_service_w->mConcurrectConnections - old_concurrent_connections; for (int i = 0; i < number_of_capability_types; ++i) { diff --git a/indra/llmessage/aicurlperservice.h b/indra/llmessage/aicurlperservice.h index bd399b6e9..bdbc1544c 100644 --- a/indra/llmessage/aicurlperservice.h +++ b/indra/llmessage/aicurlperservice.h @@ -283,7 +283,7 @@ class RefCountedThreadSafePerService : public threadsafe_PerService { friend void intrusive_ptr_release(RefCountedThreadSafePerService* p); }; -extern U32 CurlConcurrentConnectionsPerService; +extern U16 CurlConcurrentConnectionsPerService; } // namespace AICurlPrivate diff --git a/indra/llmessage/aicurlthread.cpp b/indra/llmessage/aicurlthread.cpp index e16ae7e3a..d9b5b19fa 100644 --- a/indra/llmessage/aicurlthread.cpp +++ b/indra/llmessage/aicurlthread.cpp @@ -2561,7 +2561,7 @@ void startCurlThread(LLControlGroup* control_group) // Cache Debug Settings. sConfigGroup = control_group; curl_max_total_concurrent_connections = sConfigGroup->getU32("CurlMaxTotalConcurrentConnections"); - CurlConcurrentConnectionsPerService = sConfigGroup->getU32("CurlConcurrentConnectionsPerService"); + CurlConcurrentConnectionsPerService = (U16)sConfigGroup->getU32("CurlConcurrentConnectionsPerService"); gNoVerifySSLCert = sConfigGroup->getBOOL("NoVerifySSLCert"); AIPerService::setMaxPipelinedRequests(curl_max_total_concurrent_connections); AIPerService::setHTTPThrottleBandwidth(sConfigGroup->getF32("HTTPThrottleBandwidth")); @@ -2586,10 +2586,19 @@ bool handleCurlConcurrentConnectionsPerService(LLSD const& newvalue) { using namespace AICurlPrivate; - U32 new_concurrent_connections = newvalue.asInteger(); - AIPerService::adjust_concurrent_connections(new_concurrent_connections - CurlConcurrentConnectionsPerService); - CurlConcurrentConnectionsPerService = new_concurrent_connections; - llinfos << "CurlConcurrentConnectionsPerService set to " << CurlConcurrentConnectionsPerService << llendl; + U16 new_concurrent_connections = (U16)newvalue.asInteger(); + U16 const maxCurlConcurrentConnectionsPerService = 32; + if (new_concurrent_connections < 1 || new_concurrent_connections > maxCurlConcurrentConnectionsPerService) + { + sConfigGroup->setU32("CurlConcurrentConnectionsPerService", static_cast((new_concurrent_connections < 1) ? 1 : maxCurlConcurrentConnectionsPerService)); + } + else + { + int increment = new_concurrent_connections - CurlConcurrentConnectionsPerService; + CurlConcurrentConnectionsPerService = new_concurrent_connections; + AIPerService::adjust_concurrent_connections(increment); + llinfos << "CurlConcurrentConnectionsPerService set to " << CurlConcurrentConnectionsPerService << llendl; + } return true; } diff --git a/indra/newview/app_settings/settings_crash_behavior.xml b/indra/newview/app_settings/settings_crash_behavior.xml index 433583bee..0665d86f2 100644 --- a/indra/newview/app_settings/settings_crash_behavior.xml +++ b/indra/newview/app_settings/settings_crash_behavior.xml @@ -31,7 +31,7 @@ Type U32 Value - 16 + 8 NoVerifySSLCert