From 8d334ca1bf51dc1a0020f53cdd7a3927bdb7740c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 16 Oct 2015 11:40:48 -0700 Subject: MAINT-5271: Converted internal pointers to internal operation to managed shared pointers. Removed direct cast and dereference of handles. --- indra/llcorehttp/_httppolicy.cpp | 49 ++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'indra/llcorehttp/_httppolicy.cpp') diff --git a/indra/llcorehttp/_httppolicy.cpp b/indra/llcorehttp/_httppolicy.cpp index e5d6321401..fd78a5dadc 100755 --- a/indra/llcorehttp/_httppolicy.cpp +++ b/indra/llcorehttp/_httppolicy.cpp @@ -116,21 +116,19 @@ void HttpPolicy::shutdown() HttpRetryQueue & retryq(state.mRetryQueue); while (! retryq.empty()) { - HttpOpRequest * op(retryq.top()); + HttpOpRequest::ptr_t op(retryq.top()); retryq.pop(); op->cancel(); - op->release(); } HttpReadyQueue & readyq(state.mReadyQueue); while (! readyq.empty()) { - HttpOpRequest * op(readyq.top()); + HttpOpRequest::ptr_t op(readyq.top()); readyq.pop(); op->cancel(); - op->release(); } } } @@ -141,7 +139,7 @@ void HttpPolicy::start() } -void HttpPolicy::addOp(HttpOpRequest * op) +void HttpPolicy::addOp(const HttpOpRequest::ptr_t &op) { const int policy_class(op->mReqPolicy); @@ -151,7 +149,7 @@ void HttpPolicy::addOp(HttpOpRequest * op) } -void HttpPolicy::retryOp(HttpOpRequest * op) +void HttpPolicy::retryOp(const HttpOpRequest::ptr_t &op) { static const HttpTime retry_deltas[] = { @@ -180,7 +178,7 @@ void HttpPolicy::retryOp(HttpOpRequest * op) { ++op->mPolicy503Retries; } - LL_DEBUGS(LOG_CORE) << "HTTP request " << static_cast(op) + LL_DEBUGS(LOG_CORE) << "HTTP request " << op->getHandle() << " retry " << op->mPolicyRetries << " scheduled in " << (delta / HttpTime(1000)) << " mS (" << (external_delta ? "external" : "internal") @@ -189,10 +187,10 @@ void HttpPolicy::retryOp(HttpOpRequest * op) if (op->mTracing > HTTP_TRACE_OFF) { LL_INFOS(LOG_CORE) << "TRACE, ToRetryQueue, Handle: " - << static_cast(op) - << ", Delta: " << (delta / HttpTime(1000)) - << ", Retries: " << op->mPolicyRetries - << LL_ENDL; + << op->getHandle() + << ", Delta: " << (delta / HttpTime(1000)) + << ", Retries: " << op->mPolicyRetries + << LL_ENDL; } mClasses[policy_class]->mRetryQueue.push(op); } @@ -264,14 +262,14 @@ HttpService::ELoopSpeed HttpPolicy::processReadyQueue() // First see if we have any retries... while (needed > 0 && ! retryq.empty()) { - HttpOpRequest * op(retryq.top()); + HttpOpRequest::ptr_t op(retryq.top()); if (op->mPolicyRetryAt > now) break; retryq.pop(); op->stageFromReady(mService); - op->release(); + op.reset(); ++state.mRequestCount; --needed; @@ -296,11 +294,11 @@ HttpService::ELoopSpeed HttpPolicy::processReadyQueue() // Now go on to the new requests... while (needed > 0 && ! readyq.empty()) { - HttpOpRequest * op(readyq.top()); + HttpOpRequest::ptr_t op(readyq.top()); readyq.pop(); op->stageFromReady(mService); - op->release(); + op.reset(); ++state.mRequestCount; --needed; @@ -351,9 +349,9 @@ bool HttpPolicy::changePriority(HttpHandle handle, HttpRequest::priority_t prior { HttpReadyQueue::container_type::iterator cur(iter++); - if (static_cast(*cur) == handle) + if ((*cur)->getHandle() == handle) { - HttpOpRequest * op(*cur); + HttpOpRequest::ptr_t op(*cur); c.erase(cur); // All iterators are now invalidated op->mReqPriority = priority; state.mReadyQueue.push(op); // Re-insert using adapter class @@ -378,12 +376,11 @@ bool HttpPolicy::cancel(HttpHandle handle) { HttpRetryQueue::container_type::iterator cur(iter++); - if (static_cast(*cur) == handle) + if ((*cur)->getHandle() == handle) { - HttpOpRequest * op(*cur); + HttpOpRequest::ptr_t op(*cur); c1.erase(cur); // All iterators are now invalidated op->cancel(); - op->release(); return true; } } @@ -394,12 +391,11 @@ bool HttpPolicy::cancel(HttpHandle handle) { HttpReadyQueue::container_type::iterator cur(iter++); - if (static_cast(*cur) == handle) + if ((*cur)->getHandle() == handle) { - HttpOpRequest * op(*cur); + HttpOpRequest::ptr_t op(*cur); c2.erase(cur); // All iterators are now invalidated op->cancel(); - op->release(); return true; } } @@ -409,7 +405,7 @@ bool HttpPolicy::cancel(HttpHandle handle) } -bool HttpPolicy::stageAfterCompletion(HttpOpRequest * op) +bool HttpPolicy::stageAfterCompletion(const HttpOpRequest::ptr_t &op) { // Retry or finalize if (! op->mStatus) @@ -438,7 +434,7 @@ bool HttpPolicy::stageAfterCompletion(HttpOpRequest * op) // This op is done, finalize it delivering it to the reply queue... if (! op->mStatus) { - LL_WARNS(LOG_CORE) << "HTTP request " << static_cast(op) + LL_WARNS(LOG_CORE) << "HTTP request " << op->getHandle() << " failed after " << op->mPolicyRetries << " retries. Reason: " << op->mStatus.toString() << " (" << op->mStatus.toTerseString() << ")" @@ -446,13 +442,12 @@ bool HttpPolicy::stageAfterCompletion(HttpOpRequest * op) } else if (op->mPolicyRetries) { - LL_DEBUGS(LOG_CORE) << "HTTP request " << static_cast(op) + LL_DEBUGS(LOG_CORE) << "HTTP request " << op->getHandle() << " succeeded on retry " << op->mPolicyRetries << "." << LL_ENDL; } op->stageFromActive(mService); - op->release(); return false; // not active } -- cgit v1.3 From bfabb7bd2b02654e00f5b8d12541e9bec9cbbad7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 19 Feb 2016 11:19:50 -0800 Subject: MAINT-6137: Re enable pipelining by default, use new version of CURL (7.47) with corrections for timed out connections in pipelining. Minor fix for safer op retrieval. --- autobuild.xml | 14 +++++------ indra/llcorehttp/_httplibcurl.cpp | 43 ++++++++++++++++++++++++--------- indra/llcorehttp/_httpoperation.cpp | 3 +++ indra/llcorehttp/_httpoprequest.cpp | 6 ++++- indra/llcorehttp/_httppolicy.cpp | 2 +- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llappcorehttp.cpp | 4 +-- 7 files changed, 51 insertions(+), 23 deletions(-) (limited to 'indra/llcorehttp/_httppolicy.cpp') diff --git a/autobuild.xml b/autobuild.xml index 4e8d92a979..bee2d29d9f 100755 --- a/autobuild.xml +++ b/autobuild.xml @@ -212,9 +212,9 @@ archive hash - 89db4a1aa22599cf377ae49630b7b5b1 + aaaedcd3b0b52b65181a64daa091fe10 url - http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/curl_3p-update-curl/rev/301717/arch/Darwin/installer/curl-7.42.1.301717-darwin-301717.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-curl/rev/311279/arch/Darwin/installer/curl-7.47.0.311279-darwin-311279.tar.bz2 name darwin @@ -224,9 +224,9 @@ archive hash - de9e0c855ff6ee30c9e027a70bbef032 + cfe7789e8f76c9781021ab1b9b4ec3c2 url - http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/curl_3p-update-curl/rev/301717/arch/Linux/installer/curl-7.42.1.301717-linux-301717.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-curl/rev/311279/arch/Linux/installer/curl-7.47.0.311279-linux-311279.tar.bz2 name linux @@ -236,16 +236,16 @@ archive hash - 98d15713de8c439b7f54cc14f2df07ac + 9109ad560200701443f9b41389044c38 url - http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/curl_3p-update-curl/rev/301717/arch/CYGWIN/installer/curl-7.42.1.301717-windows-301717.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-curl/rev/311279/arch/CYGWIN/installer/curl-7.47.0.311279-windows-311279.tar.bz2 name windows version - 7.42.1.301717 + 7.47.0.311279 db diff --git a/indra/llcorehttp/_httplibcurl.cpp b/indra/llcorehttp/_httplibcurl.cpp index d918c2ee1b..c25e01a318 100755 --- a/indra/llcorehttp/_httplibcurl.cpp +++ b/indra/llcorehttp/_httplibcurl.cpp @@ -301,7 +301,14 @@ bool HttpLibcurl::completeRequest(CURLM * multi_handle, CURL * handle, CURLcode { HttpHandle ophandle(NULL); - curl_easy_getinfo(handle, CURLINFO_PRIVATE, &ophandle); + CURLcode ccode(CURLE_OK); + + ccode = curl_easy_getinfo(handle, CURLINFO_PRIVATE, &ophandle); + if (ccode) + { + LL_WARNS(LOG_CORE) << "libcurl error: " << ccode << " Unable to retrieve operation handle from CURL handle" << LL_ENDL; + return false; + } HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(ophandle)); if (!op) @@ -343,22 +350,36 @@ bool HttpLibcurl::completeRequest(CURLM * multi_handle, CURL * handle, CURLcode if (handle) { - curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &http_status); - if (http_status >= 100 && http_status <= 999) + ccode = curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &http_status); + if (ccode == CURLE_OK) { - char * cont_type(NULL); - curl_easy_getinfo(handle, CURLINFO_CONTENT_TYPE, &cont_type); - if (cont_type) + if (http_status >= 100 && http_status <= 999) + { + char * cont_type(NULL); + ccode = curl_easy_getinfo(handle, CURLINFO_CONTENT_TYPE, &cont_type); + if (ccode == CURLE_OK) + { + if (cont_type) + { + op->mReplyConType = cont_type; + } + } + else + { + LL_WARNS(LOG_CORE) << "CURL error:" << ccode << " Attempting to get content type." << LL_ENDL; + } + op->mStatus = HttpStatus(http_status); + } + else { - op->mReplyConType = cont_type; + LL_WARNS(LOG_CORE) << "Invalid HTTP response code (" + << http_status << ") received from server." + << LL_ENDL; + op->mStatus = HttpStatus(HttpStatus::LLCORE, HE_INVALID_HTTP_STATUS); } - op->mStatus = HttpStatus(http_status); } else { - LL_WARNS(LOG_CORE) << "Invalid HTTP response code (" - << http_status << ") received from server." - << LL_ENDL; op->mStatus = HttpStatus(HttpStatus::LLCORE, HE_INVALID_HTTP_STATUS); } } diff --git a/indra/llcorehttp/_httpoperation.cpp b/indra/llcorehttp/_httpoperation.cpp index 333f20d281..3fc4e28910 100755 --- a/indra/llcorehttp/_httpoperation.cpp +++ b/indra/llcorehttp/_httpoperation.cpp @@ -179,6 +179,9 @@ HttpOperation::ptr_t HttpOperation::findByHandle(HttpHandle handle) { wptr_t weak; + if (!handle) + return ptr_t(); + { LLCoreInt::HttpScopedLock lock(mOpMutex); diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 557f6207b5..db57869a1b 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -750,7 +750,11 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) xfer_timeout *= 2L; } // *DEBUG: Enable following override for timeout handling and "[curl:bugs] #1420" tests - // xfer_timeout = 1L; + //if (cpolicy.mPipelining) + //{ + // xfer_timeout = 1L; + // timeout = 1L; + //} code = curl_easy_setopt(mCurlHandle, CURLOPT_TIMEOUT, xfer_timeout); check_curl_easy_code(code, CURLOPT_TIMEOUT); code = curl_easy_setopt(mCurlHandle, CURLOPT_CONNECTTIMEOUT, timeout); diff --git a/indra/llcorehttp/_httppolicy.cpp b/indra/llcorehttp/_httppolicy.cpp index fd78a5dadc..b2709b53ec 100755 --- a/indra/llcorehttp/_httppolicy.cpp +++ b/indra/llcorehttp/_httppolicy.cpp @@ -416,7 +416,7 @@ bool HttpPolicy::stageAfterCompletion(const HttpOpRequest::ptr_t &op) #if 0 if (op->mStatus == HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_OPERATION_TIMEDOUT)) { - LL_WARNS(LOG_CORE) << "HTTP request " << static_cast(op) + LL_WARNS(LOG_CORE) << "HTTP request " << op->getHandle() << " timed out." << LL_ENDL; } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 46fd9a27e3..d5549013fa 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4557,7 +4557,7 @@ Type Boolean Value - 0 + 1 HttpRangeRequestsDisable diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp index c13c4f982a..7dee309a62 100755 --- a/indra/newview/llappcorehttp.cpp +++ b/indra/newview/llappcorehttp.cpp @@ -125,7 +125,7 @@ LLAppCoreHttp::LLAppCoreHttp() mStopHandle(LLCORE_HTTP_HANDLE_INVALID), mStopRequested(0.0), mStopped(false), - mPipelined(false) + mPipelined(true) {} @@ -359,7 +359,7 @@ void LLAppCoreHttp::refreshSettings(bool initial) static const std::string http_pipelining("HttpPipelining"); if (gSavedSettings.controlExists(http_pipelining)) { - // Default to false (in ctor) if absent. + // Default to true (in ctor) if absent. bool pipelined(gSavedSettings.getBOOL(http_pipelining)); if (pipelined != mPipelined) { -- cgit v1.3