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.
This commit is contained in:
Aleric Inglewood
2013-06-23 18:05:23 +02:00
parent ee59617c5e
commit 87176418a2
4 changed files with 20 additions and 10 deletions

View File

@@ -49,7 +49,7 @@ AIThreadSafeSimpleDC<AIPerService::TotalQueued> 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)
{

View File

@@ -283,7 +283,7 @@ class RefCountedThreadSafePerService : public threadsafe_PerService {
friend void intrusive_ptr_release(RefCountedThreadSafePerService* p);
};
extern U32 CurlConcurrentConnectionsPerService;
extern U16 CurlConcurrentConnectionsPerService;
} // namespace AICurlPrivate

View File

@@ -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<U32>((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;
}

View File

@@ -31,7 +31,7 @@
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>16</integer>
<integer>8</integer>
</map>
<key>NoVerifySSLCert</key>
<map>