diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcorehttp/_httpinternal.h | 3 | ||||
-rw-r--r-- | indra/llcorehttp/_httpoprequest.cpp | 13 | ||||
-rw-r--r-- | indra/llcorehttp/_httpoprequest.h | 3 | ||||
-rw-r--r-- | indra/llmessage/llcurl.cpp | 58 | ||||
-rw-r--r-- | indra/llmessage/llcurl.h | 11 |
5 files changed, 45 insertions, 43 deletions
diff --git a/indra/llcorehttp/_httpinternal.h b/indra/llcorehttp/_httpinternal.h index 14f744a9f1..008e4fd95c 100644 --- a/indra/llcorehttp/_httpinternal.h +++ b/indra/llcorehttp/_httpinternal.h @@ -146,9 +146,6 @@ const int HTTP_SERVICE_LOOP_SLEEP_NORMAL_MS = 2; // Block allocation size (a tuning parameter) is found // in bufferarray.h. -// Compatibility controls -const bool HTTP_ENABLE_LINKSYS_WRT54G_V5_DNS_FIX = true; - } // end namespace LLCore #endif // _LLCORE_HTTP_INTERNAL_H_ diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 469ce75434..89dcd334f4 100644 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -380,18 +380,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) // Get policy options HttpPolicyGlobal & policy(service->getPolicy().getGlobalOptions()); - mCurlHandle = LLCurlHandleHandler::getInstance()->CreateCurlHandle(); - - if (HTTP_ENABLE_LINKSYS_WRT54G_V5_DNS_FIX) - { - // 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. - curl_easy_setopt(mCurlHandle, CURLOPT_DNS_CACHE_TIMEOUT, 15); - } + mCurlHandle = LLCurl::createStandardCurlHandle(); curl_easy_setopt(mCurlHandle, CURLOPT_WRITEFUNCTION, writeCallback); curl_easy_setopt(mCurlHandle, CURLOPT_READFUNCTION, readCallback); diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index e819f74079..74a349b0bf 100644 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -29,7 +29,6 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces -#include "llsingleton.h" #include <string> #include <curl/curl.h> @@ -66,8 +65,6 @@ class HttpOpRequest : public HttpOperation public: HttpOpRequest(); - friend class CurlHandleHandler; - protected: virtual ~HttpOpRequest(); // Use release() 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); } diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index a03333157c..90b3f2815d 100644 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -53,14 +53,6 @@ class LLCurlThread; // For whatever reason, this is not typedef'd in curl.h typedef size_t (*curl_header_callback)(void *ptr, size_t size, size_t nmemb, void *stream); -class LLCurlHandleHandler : public LLSingleton<LLCurlHandleHandler> -{ -public: - static CURL* the_one_true_curl_handle; - LLCurlHandleHandler(); - static CURL* CreateCurlHandle(); -}; - class LLCurl { LOG_CLASS(LLCurl); @@ -196,6 +188,8 @@ public: static CURL* newEasyHandle() ; static void deleteEasyHandle(CURL* handle) ; + static CURL* createStandardCurlHandle(); + private: static std::string sCAPath; static std::string sCAFile; @@ -205,6 +199,7 @@ private: static LLMutex* sHandleMutexp ; static S32 sTotalHandles ; static S32 sMaxHandles; + static CURL* sCurlTemplateStandardHandle; public: static bool sNotQuitting; static F32 sCurlRequestTimeOut; |