Introduce two new parameters "CurlUseMultipleThreads" and "CurlRequestTimeOut" for QA to test Curl.

meow-7.2.2
Xiaohong Bao 2012-01-25 18:27:40 -07:00
parent cc3f90a888
commit 717a6f3306
4 changed files with 38 additions and 10 deletions

View File

@ -75,9 +75,6 @@ static const S32 MULTI_PERFORM_CALL_REPEAT = 5;
static const S32 CURL_REQUEST_TIMEOUT = 30; // seconds per operation
static const S32 MAX_ACTIVE_REQUEST_COUNT = 100;
static const F32 DEFAULT_MULTI_IDLE_TIME = 120.0f ; //seconds
static const S32 MAX_NUM_OF_HANDLES = 256 ; //max number of handles, (multi handles and easy handles combined).
// DEBUG //
S32 gCurlEasyCount = 0;
S32 gCurlMultiCount = 0;
@ -92,6 +89,8 @@ LLCurlThread* LLCurl::sCurlThread = NULL ;
LLMutex* LLCurl::sHandleMutexp = NULL ;
S32 LLCurl::sTotalHandles = 0 ;
bool LLCurl::sNotQuitting = true;
F32 LLCurl::sCurlRequestTimeOut = 120.f; //seonds
S32 LLCurl::sMaxHandles = 256; //max number of handles, (multi handles and easy handles combined).
void check_curl_code(CURLcode code)
{
@ -573,9 +572,9 @@ LLCurl::Multi::Multi(F32 idle_time_out)
LLCurl::getCurlThread()->addMulti(this) ;
mIdleTimeOut = idle_time_out ;
if(mIdleTimeOut < DEFAULT_MULTI_IDLE_TIME)
if(mIdleTimeOut < LLCurl::sCurlRequestTimeOut)
{
mIdleTimeOut = DEFAULT_MULTI_IDLE_TIME ;
mIdleTimeOut = LLCurl::sCurlRequestTimeOut ;
}
++gCurlMultiCount;
@ -1442,8 +1441,11 @@ unsigned long LLCurl::ssl_thread_id(void)
}
#endif
void LLCurl::initClass(bool multi_threaded)
void LLCurl::initClass(F32 curl_reuest_timeout, S32 max_number_handles, bool multi_threaded)
{
sCurlRequestTimeOut = curl_reuest_timeout ; //seconds
sMaxHandles = max_number_handles ; //max number of handles, (multi handles and easy handles combined).
// Do not change this "unless you are familiar with and mean to control
// internal operations of libcurl"
// - http://curl.haxx.se/libcurl/c/curl_global_init.html
@ -1512,7 +1514,7 @@ CURLM* LLCurl::newMultiHandle()
{
LLMutexLock lock(sHandleMutexp) ;
if(sTotalHandles + 1 > MAX_NUM_OF_HANDLES)
if(sTotalHandles + 1 > sMaxHandles)
{
llwarns << "no more handles available." << llendl ;
return NULL ; //failed
@ -1545,7 +1547,7 @@ CURL* LLCurl::newEasyHandle()
{
LLMutexLock lock(sHandleMutexp) ;
if(sTotalHandles + 1 > MAX_NUM_OF_HANDLES)
if(sTotalHandles + 1 > sMaxHandles)
{
llwarns << "no more handles available." << llendl ;
return NULL ; //failed

View File

@ -163,7 +163,7 @@ public:
/**
* @ brief Initialize LLCurl class
*/
static void initClass(bool multi_threaded = false);
static void initClass(F32 curl_reuest_timeout = 120.f, S32 max_number_handles = 256, bool multi_threaded = false);
/**
* @ brief Cleanup LLCurl class
@ -197,8 +197,10 @@ private:
static LLMutex* sHandleMutexp ;
static S32 sTotalHandles ;
static S32 sMaxHandles;
public:
static bool sNotQuitting;
static F32 sCurlRequestTimeOut;
};
class LLCurl::Easy

View File

@ -1828,6 +1828,28 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>CurlMaximumNumberOfHandles</key>
<map>
<key>Comment</key>
<string>Maximum number of handles curl can use (requires restart)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>S32</string>
<key>Value</key>
<integer>256</integer>
</map>
<key>CurlRequestTimeOut</key>
<map>
<key>Comment</key>
<string>Max idle time of a curl request before killed (requires restart)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>120.0</real>
</map>
<key>CurlUseMultipleThreads</key>
<map>
<key>Comment</key>

View File

@ -720,7 +720,9 @@ bool LLAppViewer::init()
// *NOTE:Mani - LLCurl::initClass is not thread safe.
// Called before threads are created.
LLCurl::initClass(gSavedSettings.getBOOL("CurlUseMultipleThreads"));
LLCurl::initClass(gSavedSettings.getF32("CurlRequestTimeOut"),
gSavedSettings.getS32("CurlMaximumNumberOfHandles"),
gSavedSettings.getBOOL("CurlUseMultipleThreads"));
LL_INFOS("InitInfo") << "LLCurl initialized." << LL_ENDL ;
LLMachineID::init();