summaryrefslogtreecommitdiff
path: root/indra/llmessage/llcurl.cpp
diff options
context:
space:
mode:
authorsimon <none@none>2013-04-25 14:14:35 -0700
committersimon <none@none>2013-04-25 14:14:35 -0700
commit6e483af1f6b7a6f8d0f83e54d79a941607760f7b (patch)
tree7e9673f54b1aed046d7b3cc6596877fd966e715e /indra/llmessage/llcurl.cpp
parentc4a45fca396bea8abf8362b15b5cf0f85e57ad6b (diff)
Revert ares and libcurl version update that was causing problems, revise curl
handle duplication code. Reviewed by Kelly
Diffstat (limited to 'indra/llmessage/llcurl.cpp')
-rw-r--r--indra/llmessage/llcurl.cpp58
1 files changed, 41 insertions, 17 deletions
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index c02483ccf5..081f070866 100644
--- 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,7 +1816,7 @@ CURL* LLCurl::newEasyHandle()
}
sTotalHandles++;
- CURL* ret = LLCurlHandleHandler::getInstance()->CreateCurlHandle();
+ CURL* ret = createStandardCurlHandle();
if(!ret)
{
llwarns << "failed to create curl handle." << llendl ;
@@ -1849,23 +1850,46 @@ void LLCurlFF::check_multi_code(CURLMcode code)
check_curl_multi_code(code);
}
-CURL* LLCurlHandleHandler::the_one_true_curl_handle;
-LLCurlHandleHandler::LLCurlHandleHandler()
+// Static
+CURL* LLCurl::createStandardCurlHandle()
{
- the_one_true_curl_handle = curl_easy_init();
- curl_easy_setopt(the_one_true_curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
- curl_easy_setopt(the_one_true_curl_handle, CURLOPT_NOSIGNAL, 1);
- curl_easy_setopt(the_one_true_curl_handle, CURLOPT_NOPROGRESS, 1);
- curl_easy_setopt(the_one_true_curl_handle, CURLOPT_ENCODING, "");
- curl_easy_setopt(the_one_true_curl_handle, CURLOPT_AUTOREFERER, 1);
- curl_easy_setopt(the_one_true_curl_handle, CURLOPT_FOLLOWLOCATION, 1);
- curl_easy_setopt(the_one_true_curl_handle, CURLOPT_SSL_VERIFYPEER, 1);
- curl_easy_setopt(the_one_true_curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
- curl_easy_setopt(the_one_true_curl_handle, CURLOPT_DNS_CACHE_TIMEOUT, 0);
-}
+ 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);
+ }
+ }
-CURL* LLCurlHandleHandler::CreateCurlHandle()
-{
- return curl_easy_duphandle(the_one_true_curl_handle);
+ return curl_easy_duphandle(sCurlTemplateStandardHandle);
}