From 2a7b96fab24a0b28a53f542081946f1216c93b39 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Thu, 21 Nov 2013 19:47:25 +0100 Subject: [PATCH] Increase connect time outs for SSL/TLS connections to 30 seconds. On (very) slow machines this might improve the experience. This only has effect on Second Life, since that's currently the only grid that uses https for capabilities (all of them, except GetMesh, GetMesh2 and GetTexture). When linking the viewer with libmemleak, which significantly slows down calls to malloc (and calloc, realloc, new, memalign and so on) and free (delete), I no longer could download my inventory. With this patch this was solved. The reason was that completing the SSL/TLS handshake took more than 10 seconds (15 to 20). --- indra/llmessage/aicurl.cpp | 9 ++++++++- indra/llmessage/aicurlprivate.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/indra/llmessage/aicurl.cpp b/indra/llmessage/aicurl.cpp index 1364b4e38..6b2101a4d 100644 --- a/indra/llmessage/aicurl.cpp +++ b/indra/llmessage/aicurl.cpp @@ -1095,6 +1095,7 @@ void CurlEasyRequest::finalizeRequest(std::string const& url, AIHTTPTimeoutPolic DoutCurlEntering("CurlEasyRequest::finalizeRequest(\"" << url << "\", " << policy.name() << ", " << (void*)state_machine << ")"); llassert(!mTimeoutPolicy); // May only call finalizeRequest once! mResult = CURLE_FAILED_INIT; // General error code; the final result code is stored here by MultiHandle::check_msg_queue when msg is CURLMSG_DONE. + mIsHttps = strncmp(url.c_str(), "https:", 6) == 0; #ifdef SHOW_ASSERT // Do a sanity check on the headers. int content_type_count = 0; @@ -1139,7 +1140,13 @@ void CurlEasyRequest::finalizeRequest(std::string const& url, AIHTTPTimeoutPolic // // get less connect time, while it still (also) has to wait for this DNS lookup. void CurlEasyRequest::set_timeout_opts(void) { - setopt(CURLOPT_CONNECTTIMEOUT, mTimeoutPolicy->getConnectTimeout(getLowercaseHostname())); + U16 connect_timeout = mTimeoutPolicy->getConnectTimeout(getLowercaseHostname()); + if (mIsHttps && connect_timeout < 30) + { + DoutCurl("Incrementing CURLOPT_CONNECTTIMEOUT of \"" << mTimeoutPolicy->name() << "\" from " << connect_timeout << " to 30 seconds."); + connect_timeout = 30; + } + setopt(CURLOPT_CONNECTTIMEOUT, connect_timeout); setopt(CURLOPT_TIMEOUT, mTimeoutPolicy->getCurlTransaction()); } diff --git a/indra/llmessage/aicurlprivate.h b/indra/llmessage/aicurlprivate.h index ddf685aca..f2230d179 100644 --- a/indra/llmessage/aicurlprivate.h +++ b/indra/llmessage/aicurlprivate.h @@ -315,6 +315,7 @@ class CurlEasyRequest : public CurlEasyHandle { AIPerServicePtr mPerServicePtr; // Pointer to the corresponding AIPerService. LLPointer mTimeout;// Timeout administration object associated with last created CurlSocketInfo. bool mTimeoutIsOrphan; // Set to true when mTimeout is not (yet) associated with a CurlSocketInfo. + bool mIsHttps; // Set if the url starts with "https:". #if defined(CWDEBUG) || defined(DEBUG_CURLIO) public: bool mDebugIsHeadOrGetMethod;