diff options
author | dolphin <dolphin@lindenlab.com> | 2013-10-04 09:19:25 -0700 |
---|---|---|
committer | dolphin <dolphin@lindenlab.com> | 2013-10-04 09:19:25 -0700 |
commit | c2c060d4401d3a79a9ae0076af0c9b86d14f7f37 (patch) | |
tree | b7efcf3c2e38aa9de488342b3379b4bde0a6bc47 /indra/llmessage/llcurl.cpp | |
parent | d44c85c6dc575c0c67019ce1bffecfaa5bc275d1 (diff) | |
parent | f7158bc5afcec1da8b9d2d5a4ed86921e62d4959 (diff) |
Merge with 3.6.7
Diffstat (limited to 'indra/llmessage/llcurl.cpp')
-rwxr-xr-x | indra/llmessage/llcurl.cpp | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index f2a3e059ef..081f070866 100755 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -92,6 +92,7 @@ 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). +CURL* LLCurl::sCurlTemplateStandardHandle = NULL; void check_curl_code(CURLcode code) { @@ -1815,10 +1816,10 @@ CURL* LLCurl::newEasyHandle() } sTotalHandles++; - CURL* ret = curl_easy_init() ; + CURL* ret = createStandardCurlHandle(); if(!ret) { - llwarns << "curl_easy_init failed." << llendl ; + llwarns << "failed to create curl handle." << llendl ; } return ret ; @@ -1848,3 +1849,47 @@ void LLCurlFF::check_multi_code(CURLMcode code) { check_curl_multi_code(code); } + + +// Static +CURL* LLCurl::createStandardCurlHandle() +{ + if (sCurlTemplateStandardHandle == NULL) + { // Late creation of the template curl handle + sCurlTemplateStandardHandle = curl_easy_init(); + if (sCurlTemplateStandardHandle == NULL) + { + llwarns << "curl error calling curl_easy_init()" << llendl; + } + else + { + CURLcode result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_NOSIGNAL, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_NOPROGRESS, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_ENCODING, ""); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_AUTOREFERER, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_FOLLOWLOCATION, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_SSL_VERIFYPEER, 1); + check_curl_code(result); + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_SSL_VERIFYHOST, 0); + check_curl_code(result); + + // The Linksys WRT54G V5 router has an issue with frequent + // DNS lookups from LAN machines. If they happen too often, + // like for every HTTP request, the router gets annoyed after + // about 700 or so requests and starts issuing TCP RSTs to + // new connections. Reuse the DNS lookups for even a few + // seconds and no RSTs. + result = curl_easy_setopt(sCurlTemplateStandardHandle, CURLOPT_DNS_CACHE_TIMEOUT, 15); + check_curl_code(result); + } + } + + return curl_easy_duphandle(sCurlTemplateStandardHandle); +} |