Allow changing CurlTimeout Debug Settings on the fly.

Same for NoVerifySSLCert and CurlConcurrentConnections.
This commit is contained in:
Aleric Inglewood
2012-10-30 21:18:15 +01:00
parent 9996cf6157
commit 3708d55ef9
6 changed files with 196 additions and 11 deletions

View File

@@ -55,6 +55,7 @@
#include "llhttpstatuscodes.h"
#include "aihttpheaders.h"
// Debug Settings.
extern bool gNoVerifySSLCert;
class LLSD;
@@ -148,6 +149,10 @@ struct TransferInfo {
//-----------------------------------------------------------------------------
// Global functions.
// Called to handle changes in Debug Settings.
bool handleCurlConcurrentConnections(LLSD const& newvalue);
bool handleNoVerifySSLCert(LLSD const& newvalue);
// Called once at start of application (from newview/llappviewer.cpp by main thread (before threads are created)),
// with main purpose to initialize curl.
void initCurl(void (*)(void) = NULL);

View File

@@ -2493,5 +2493,20 @@ void startCurlThread(U32 CurlConcurrentConnections, bool NoVerifySSLCert)
AICurlThread::sInstance->start();
}
bool handleCurlConcurrentConnections(LLSD const& newvalue)
{
using namespace AICurlPrivate::curlthread;
curl_concurrent_connections = newvalue.asInteger();
llinfos << "CurlConcurrentConnections set to " << curl_concurrent_connections << llendl;
return true;
}
bool handleNoVerifySSLCert(LLSD const& newvalue)
{
gNoVerifySSLCert = newvalue.asBoolean();
return true;
}
} // namespace AICurlInterface

View File

@@ -602,8 +602,6 @@ void AIHTTPTimeoutPolicy::sanity_checks(void) const
//=======================================================================================================
// Start of policy definitions.
// AIFIXME: update all policies whenever a CurlTimeout* settings is changed.
// Policy with hardcoded default values.
AIHTTPTimeoutPolicyBase HTTPTimeoutPolicy_default(
AITP_default_DNS_lookup_grace,
@@ -646,6 +644,132 @@ AIHTTPTimeoutPolicyBase connect_40s(AIHTTPTimeoutPolicyBase::getDebugSettingsCur
// End of policy definitions.
//=======================================================================================================
bool validateCurlTimeoutDNSLookup(LLSD const& newvalue)
{
U32 new_value = newvalue.asInteger();
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::DNS op(new_value);
op.perform(&timeout);
return timeout.getDNSLookup() == new_value;
}
bool handleCurlTimeoutDNSLookup(LLSD const& newvalue)
{
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::DNS op(newvalue.asInteger());
op.perform(&timeout);
AIHTTPTimeoutPolicy::setDefaultCurlTimeout(timeout);
return true;
}
bool validateCurlTimeoutConnect(LLSD const& newvalue)
{
U32 new_value = newvalue.asInteger();
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Connect op(new_value);
op.perform(&timeout);
return timeout.getConnect() == new_value;
}
bool handleCurlTimeoutConnect(LLSD const& newvalue)
{
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Connect op(newvalue.asInteger());
op.perform(&timeout);
AIHTTPTimeoutPolicy::setDefaultCurlTimeout(timeout);
return true;
}
bool validateCurlTimeoutReplyDelay(LLSD const& newvalue)
{
U32 new_value = newvalue.asInteger();
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Reply op(new_value);
op.perform(&timeout);
return timeout.getReplyDelay() == new_value;
}
bool handleCurlTimeoutReplyDelay(LLSD const& newvalue)
{
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Reply op(newvalue.asInteger());
op.perform(&timeout);
AIHTTPTimeoutPolicy::setDefaultCurlTimeout(timeout);
return true;
}
bool validateCurlTimeoutLowSpeedLimit(LLSD const& newvalue)
{
U32 new_value = newvalue.asInteger();
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Speed op(timeout.getLowSpeedTime(), new_value);
op.perform(&timeout);
return timeout.getLowSpeedLimit() == new_value;
}
bool handleCurlTimeoutLowSpeedLimit(LLSD const& newvalue)
{
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Speed op(timeout.getLowSpeedTime(), newvalue.asInteger());
op.perform(&timeout);
AIHTTPTimeoutPolicy::setDefaultCurlTimeout(timeout);
return true;
}
bool validateCurlTimeoutLowSpeedTime(LLSD const& newvalue)
{
U32 new_value = newvalue.asInteger();
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Speed op(new_value, timeout.getLowSpeedLimit());
op.perform(&timeout);
return timeout.getLowSpeedTime() == new_value;
}
bool handleCurlTimeoutLowSpeedTime(LLSD const& newvalue)
{
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Speed op(newvalue.asInteger(), timeout.getLowSpeedLimit());
op.perform(&timeout);
AIHTTPTimeoutPolicy::setDefaultCurlTimeout(timeout);
return true;
}
bool validateCurlTimeoutMaxTransaction(LLSD const& newvalue)
{
U32 new_value = newvalue.asInteger();
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Transaction op(new_value);
op.perform(&timeout);
return timeout.getCurlTransaction() == new_value;
}
bool handleCurlTimeoutMaxTransaction(LLSD const& newvalue)
{
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Transaction op(newvalue.asInteger());
op.perform(&timeout);
AIHTTPTimeoutPolicy::setDefaultCurlTimeout(timeout);
return true;
}
bool validateCurlTimeoutMaxTotalDelay(LLSD const& newvalue)
{
U32 new_value = newvalue.asInteger();
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Total op(new_value);
op.perform(&timeout);
return timeout.getTotalDelay() == new_value;
}
bool handleCurlTimeoutMaxTotalDelay(LLSD const& newvalue)
{
AIHTTPTimeoutPolicyBase timeout = AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout();
AIHTTPTimeoutPolicyOperators::Total op(newvalue.asInteger());
op.perform(&timeout);
AIHTTPTimeoutPolicy::setDefaultCurlTimeout(timeout);
return true;
}
//static
AIHTTPTimeoutPolicy::namemap_t AIHTTPTimeoutPolicy::sNameMap;

View File

@@ -94,6 +94,8 @@ class AIHTTPTimeoutPolicy {
// Accessors.
char const* name(void) const { return mName; }
U16 getConnectTimeout(std::string const& hostname) const;
U16 getDNSLookup(void) const { return mDNSLookupGrace; }
U16 getConnect(void) const { return mMaximumConnectTime; }
U16 getReplyDelay(void) const { return mMaximumReplyDelay; }
U16 getLowSpeedTime(void) const { return mLowSpeedTime; }
U32 getLowSpeedLimit(void) const { return mLowSpeedLimit; }
@@ -115,4 +117,22 @@ class AIHTTPTimeoutPolicy {
AIHTTPTimeoutPolicy& operator=(AIHTTPTimeoutPolicy const&);
};
class LLSD;
// Handlers for Debug Setting changes.
bool validateCurlTimeoutDNSLookup(LLSD const& newvalue);
bool handleCurlTimeoutDNSLookup(LLSD const& newvalue);
bool validateCurlTimeoutConnect(LLSD const& newvalue);
bool handleCurlTimeoutConnect(LLSD const& newvalue);
bool validateCurlTimeoutReplyDelay(LLSD const& newvalue);
bool handleCurlTimeoutReplyDelay(LLSD const& newvalue);
bool validateCurlTimeoutLowSpeedLimit(LLSD const& newvalue);
bool handleCurlTimeoutLowSpeedLimit(LLSD const& newvalue);
bool validateCurlTimeoutLowSpeedTime(LLSD const& newvalue);
bool handleCurlTimeoutLowSpeedTime(LLSD const& newvalue);
bool validateCurlTimeoutMaxTransaction(LLSD const& newvalue);
bool handleCurlTimeoutMaxTransaction(LLSD const& newvalue);
bool validateCurlTimeoutMaxTotalDelay(LLSD const& newvalue);
bool handleCurlTimeoutMaxTotalDelay(LLSD const& newvalue);
#endif // AIHTTPTIMEOUTPOLICY_H

View File

@@ -4208,7 +4208,7 @@
<key>CurlConcurrentConnections</key>
<map>
<key>Comment</key>
<string>Maximum number of simultaneous curl connections (requires restart)</string>
<string>Maximum number of simultaneous curl connections</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -4230,7 +4230,7 @@
<key>CurlTimeoutDNSLookup</key>
<map>
<key>Comment</key>
<string>Extra time in seconds added to CurlTimeoutConnect for the initial connect to a host (requires restart)</string>
<string>Extra time in seconds added to CurlTimeoutConnect for the initial connect to a host</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -4241,7 +4241,7 @@
<key>CurlTimeoutConnect</key>
<map>
<key>Comment</key>
<string>Maximum time allowed until a connection is established (after adding the easy handle) until the server is considered unreachable and the connection is terminated (requires restart)</string>
<string>Maximum time allowed until a connection is established (after adding the easy handle) until the server is considered unreachable and the connection is terminated</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -4252,7 +4252,7 @@
<key>CurlTimeoutReplyDelay</key>
<map>
<key>Comment</key>
<string>Maximum time the viewer will wait between sending data to the server and receiving (a partial) reply (requires restart)</string>
<string>Maximum time the viewer will wait between sending data to the server and receiving (a partial) reply</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -4263,7 +4263,7 @@
<key>CurlTimeoutLowSpeedLimit</key>
<map>
<key>Comment</key>
<string>If a transfer speed drops below this value (in bytes/s) during CurlTimeoutLowSpeedTime seconds, the transfer is considered too slow and is terminated (requires restart)</string>
<string>If a transfer speed drops below this value (in bytes/s) during CurlTimeoutLowSpeedTime seconds, the transfer is considered too slow and is terminated</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -4274,7 +4274,7 @@
<key>CurlTimeoutLowSpeedTime</key>
<map>
<key>Comment</key>
<string>If a transfer speed drops below CurlTimeoutLowSpeedLimit (in bytes/s) during this amount of seconds, the transfer is considered too slow and is terminated (requires restart)</string>
<string>If a transfer speed drops below CurlTimeoutLowSpeedLimit (in bytes/s) during this amount of seconds, the transfer is considered too slow and is terminated</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -4285,7 +4285,7 @@
<key>CurlTimeoutMaxTransaction</key>
<map>
<key>Comment</key>
<string>Maximum total time of a curl transaction, from when the easy handle is added till the transaction has completed. This INCLUDES DNS lookups (CurlTimeoutConnect), connect time (CurlTimeoutConnect) and waiting for the first server reply (CurlTimeoutReply) as well as the actually time needed for data transfer (requires restart)</string>
<string>Maximum total time of a curl transaction, from when the easy handle is added till the transaction has completed. This INCLUDES DNS lookups (CurlTimeoutDNSLookup), connect time (CurlTimeoutConnect) and waiting for the first server reply (CurlTimeoutReply) as well as the actually time needed for data transfer</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -4296,7 +4296,7 @@
<key>CurlTimeoutMaxTotalDelay</key>
<map>
<key>Comment</key>
<string>Maximum total time of a curl request, from when it is requested till the transaction has completed. This includes queuing due to connection throttling on top of the events covered by CurlTimeoutMaxTransaction (requires restart)</string>
<string>Maximum total time of a curl request, from when it is requested till the transaction has completed. This includes queuing due to connection throttling on top of the events covered by CurlTimeoutMaxTransaction</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -9059,7 +9059,7 @@
<key>NoVerifySSLCert</key>
<map>
<key>Comment</key>
<string>Do not verify SSL peers (requires restart)</string>
<string>Do not verify SSL peers</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>

View File

@@ -82,6 +82,8 @@
#include "aithreadsafe.h"
#include "lldrawpoolbump.h"
#include "emeraldboobutils.h"
#include "aicurl.h"
#include "aihttptimeoutpolicy.h"
#include "NACLantispam.h" // for NaCl Antispam Registry
@@ -625,6 +627,7 @@ static bool handleAllowLargeSounds(const LLSD& newvalue)
gAudiop->setAllowLargeSounds(newvalue.asBoolean());
return true;
}
////////////////////////////////////////////////////////////////////////////
void settings_setup_listeners()
{
@@ -793,6 +796,24 @@ void settings_setup_listeners()
gSavedSettings.getControl("AscentAvatarYModifier")->getSignal()->connect(boost::bind(&handleAscentAvatarModifier, _2));
gSavedSettings.getControl("AscentAvatarZModifier")->getSignal()->connect(boost::bind(&handleAscentAvatarModifier, _2));
gSavedSettings.getControl("CurlConcurrentConnections")->getSignal()->connect(boost::bind(&AICurlInterface::handleCurlConcurrentConnections, _2));
gSavedSettings.getControl("NoVerifySSLCert")->getSignal()->connect(boost::bind(&AICurlInterface::handleNoVerifySSLCert, _2));
gSavedSettings.getControl("CurlTimeoutDNSLookup")->getValidateSignal()->connect(boost::bind(&validateCurlTimeoutDNSLookup, _2));
gSavedSettings.getControl("CurlTimeoutDNSLookup")->getSignal()->connect(boost::bind(&handleCurlTimeoutDNSLookup, _2));
gSavedSettings.getControl("CurlTimeoutConnect")->getValidateSignal()->connect(boost::bind(&validateCurlTimeoutConnect, _2));
gSavedSettings.getControl("CurlTimeoutConnect")->getSignal()->connect(boost::bind(&handleCurlTimeoutConnect, _2));
gSavedSettings.getControl("CurlTimeoutReplyDelay")->getValidateSignal()->connect(boost::bind(&validateCurlTimeoutReplyDelay, _2));
gSavedSettings.getControl("CurlTimeoutReplyDelay")->getSignal()->connect(boost::bind(&handleCurlTimeoutReplyDelay, _2));
gSavedSettings.getControl("CurlTimeoutLowSpeedLimit")->getValidateSignal()->connect(boost::bind(&validateCurlTimeoutLowSpeedLimit, _2));
gSavedSettings.getControl("CurlTimeoutLowSpeedLimit")->getSignal()->connect(boost::bind(&handleCurlTimeoutLowSpeedLimit, _2));
gSavedSettings.getControl("CurlTimeoutLowSpeedTime")->getValidateSignal()->connect(boost::bind(&validateCurlTimeoutLowSpeedTime, _2));
gSavedSettings.getControl("CurlTimeoutLowSpeedTime")->getSignal()->connect(boost::bind(&handleCurlTimeoutLowSpeedTime, _2));
gSavedSettings.getControl("CurlTimeoutMaxTransaction")->getValidateSignal()->connect(boost::bind(&validateCurlTimeoutMaxTransaction, _2));
gSavedSettings.getControl("CurlTimeoutMaxTransaction")->getSignal()->connect(boost::bind(&handleCurlTimeoutMaxTransaction, _2));
gSavedSettings.getControl("CurlTimeoutMaxTotalDelay")->getValidateSignal()->connect(boost::bind(&validateCurlTimeoutMaxTotalDelay, _2));
gSavedSettings.getControl("CurlTimeoutMaxTotalDelay")->getSignal()->connect(boost::bind(&handleCurlTimeoutMaxTotalDelay, _2));
// [Ansariel: Display name support]
gSavedSettings.getControl("PhoenixNameSystem")->getSignal()->connect(boost::bind(&handlePhoenixNameSystemChanged, _2));
// [/Ansariel: Display name support]