summaryrefslogtreecommitdiff
path: root/indra/llmessage/llcurl.cpp
diff options
context:
space:
mode:
authorMonty Brandenberg <monty@lindenlab.com>2013-10-04 15:36:52 -0400
committerMonty Brandenberg <monty@lindenlab.com>2013-10-04 15:36:52 -0400
commit6f5790da38b3005292d3dbeaad778ea740110e33 (patch)
treeb28ce7a7a158f72f4dbfda60bafff2317c671837 /indra/llmessage/llcurl.cpp
parent56e2f11417183d8dcc3d681f79fc63446b236abb (diff)
parentf7158bc5afcec1da8b9d2d5a4ed86921e62d4959 (diff)
Merge. Pull in viewer-release after 3.6.7 release.
Diffstat (limited to 'indra/llmessage/llcurl.cpp')
-rwxr-xr-xindra/llmessage/llcurl.cpp49
1 files changed, 47 insertions, 2 deletions
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 5193799ade..efbc804cbc 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)
{
@@ -1818,10 +1819,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 ;
@@ -1851,3 +1852,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);
+}