diff options
Diffstat (limited to 'indra/llcorehttp')
-rw-r--r-- | indra/llcorehttp/CMakeLists.txt | 42 | ||||
-rw-r--r-- | indra/llcorehttp/_httpinternal.h | 52 | ||||
-rw-r--r-- | indra/llcorehttp/_httplibcurl.cpp | 12 | ||||
-rw-r--r-- | indra/llcorehttp/_httplibcurl.h | 6 | ||||
-rw-r--r-- | indra/llcorehttp/_httpoprequest.cpp | 9 | ||||
-rw-r--r-- | indra/llcorehttp/_httppolicy.cpp | 6 | ||||
-rw-r--r-- | indra/llcorehttp/_httpservice.cpp | 2 | ||||
-rw-r--r-- | indra/llcorehttp/bufferarray.cpp | 2 | ||||
-rw-r--r-- | indra/llcorehttp/bufferarray.h | 1 | ||||
-rw-r--r-- | indra/llcorehttp/examples/http_texture_load.cpp | 8 | ||||
-rw-r--r-- | indra/llcorehttp/httpcommon.h | 6 | ||||
-rw-r--r-- | indra/llcorehttp/httprequest.cpp | 2 | ||||
-rw-r--r-- | indra/llcorehttp/httpstats.h | 12 | ||||
-rwxr-xr-x | indra/llcorehttp/tests/llcorehttp_test.cpp | 5 | ||||
-rw-r--r-- | indra/llcorehttp/tests/test_httpoperation.hpp | 2 |
15 files changed, 63 insertions, 104 deletions
diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt index 87796abd3c..b141171516 100644 --- a/indra/llcorehttp/CMakeLists.txt +++ b/indra/llcorehttp/CMakeLists.txt @@ -3,7 +3,6 @@ project(llcorehttp) include(00-Common) -include(GoogleMock) include(CURL) include(OpenSSL) include(NGHTTP2) @@ -11,7 +10,6 @@ include(ZLIBNG) include(LLCoreHttp) include(LLAddBuildTest) include(LLCommon) -include(Tut) include(bugsplat) set(llcorehttp_SOURCE_FILES @@ -133,46 +131,6 @@ if (LL_TESTS AND LLCOREHTTP_TESTS) "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llcorehttp_peer.py" ) -if (DARWIN) - # Path inside the app bundle where we'll need to copy libraries - set(LL_TEST_DESTINATION_DIR - ${CMAKE_BINARY_DIR}/sharedlibs/$<IF:$<BOOL:${LL_GENERATOR_IS_MULTI_CONFIG}>,,../>Resources - ) - - # Create the Contents/Resources directory - add_custom_command( - TARGET INTEGRATION_TEST_llcorehttp PRE_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS - -E - make_directory - ${LL_TEST_DESTINATION_DIR} - COMMENT "Creating Resources directory in app bundle." - ) - - # Copy the required libraries to the package app. We used to use a sequence - # of '${CMAKE_COMMAND} -E copy' commands, but 'cmake -E copy' does only a - # single file at a time: it doesn't understand wildcards. 'cmake -E copy' is - # for portability. This operation is Darwin-specific. We can count on the - # 'cp' command. - set(copy_dylibs - libapr-1.0.dylib - libaprutil-1.0.dylib - libnghttp2*.dylib - liburiparser*.dylib - ${EXPAT_COPY} - ) - - add_custom_command(TARGET INTEGRATION_TEST_llcorehttp PRE_BUILD - WORKING_DIRECTORY "${AUTOBUILD_INSTALL_DIR}/lib/release" - COMMAND cp -v - ${copy_dylibs} - ${LL_TEST_DESTINATION_DIR} - DEPENDS ${copy_dylibs} - ) - -endif (DARWIN) - # # Example Programs # diff --git a/indra/llcorehttp/_httpinternal.h b/indra/llcorehttp/_httpinternal.h index 768ef98330..2a191fa550 100644 --- a/indra/llcorehttp/_httpinternal.h +++ b/indra/llcorehttp/_httpinternal.h @@ -106,17 +106,17 @@ namespace LLCore // Maxium number of policy classes that can be defined. // *TODO: Currently limited to the default class + 1, extend. // (TSN: should this be more dynamically sized. Is there a reason to hard limit the number of policies?) -const int HTTP_POLICY_CLASS_LIMIT = 32; +constexpr int HTTP_POLICY_CLASS_LIMIT = 32; // Debug/informational tracing. Used both // as a global option and in per-request traces. -const int HTTP_TRACE_OFF = 0; -const int HTTP_TRACE_LOW = 1; -const int HTTP_TRACE_CURL_HEADERS = 2; -const int HTTP_TRACE_CURL_BODIES = 3; +constexpr int HTTP_TRACE_OFF = 0; +constexpr int HTTP_TRACE_LOW = 1; +constexpr int HTTP_TRACE_CURL_HEADERS = 2; +constexpr int HTTP_TRACE_CURL_BODIES = 3; -const int HTTP_TRACE_MIN = HTTP_TRACE_OFF; -const int HTTP_TRACE_MAX = HTTP_TRACE_CURL_BODIES; +constexpr int HTTP_TRACE_MIN = HTTP_TRACE_OFF; +constexpr int HTTP_TRACE_MAX = HTTP_TRACE_CURL_BODIES; // Request retry limits // @@ -127,41 +127,41 @@ const int HTTP_TRACE_MAX = HTTP_TRACE_CURL_BODIES; // We want to span a few windows to allow transport to slow // after onset of the throttles and then recover without a final // failure. Other systems may need other constants. -const int HTTP_RETRY_COUNT_DEFAULT = 5; -const int HTTP_RETRY_COUNT_MIN = 0; -const int HTTP_RETRY_COUNT_MAX = 100; -const HttpTime HTTP_RETRY_BACKOFF_MIN_DEFAULT = 1E6L; // 1 sec -const HttpTime HTTP_RETRY_BACKOFF_MAX_DEFAULT = 5E6L; // 5 sec -const HttpTime HTTP_RETRY_BACKOFF_MAX = 20E6L; // 20 sec +constexpr int HTTP_RETRY_COUNT_DEFAULT = 5; +constexpr int HTTP_RETRY_COUNT_MIN = 0; +constexpr int HTTP_RETRY_COUNT_MAX = 100; +constexpr HttpTime HTTP_RETRY_BACKOFF_MIN_DEFAULT = 1000000UL; // 1 sec +constexpr HttpTime HTTP_RETRY_BACKOFF_MAX_DEFAULT = 50000006UL; // 5 sec +constexpr HttpTime HTTP_RETRY_BACKOFF_MAX = 20000000UL; // 20 sec -const int HTTP_REDIRECTS_DEFAULT = 10; +constexpr int HTTP_REDIRECTS_DEFAULT = 10; // Timeout value used for both connect and protocol exchange. // Retries and time-on-queue are not included and aren't // accounted for. -const long HTTP_REQUEST_TIMEOUT_DEFAULT = 30L; -const long HTTP_REQUEST_XFER_TIMEOUT_DEFAULT = 0L; -const long HTTP_REQUEST_TIMEOUT_MIN = 0L; -const long HTTP_REQUEST_TIMEOUT_MAX = 3600L; +constexpr long HTTP_REQUEST_TIMEOUT_DEFAULT = 30L; +constexpr long HTTP_REQUEST_XFER_TIMEOUT_DEFAULT = 0L; +constexpr long HTTP_REQUEST_TIMEOUT_MIN = 0L; +constexpr long HTTP_REQUEST_TIMEOUT_MAX = 3600L; // Limits on connection counts -const int HTTP_CONNECTION_LIMIT_DEFAULT = 8; -const int HTTP_CONNECTION_LIMIT_MIN = 1; -const int HTTP_CONNECTION_LIMIT_MAX = 256; +constexpr int HTTP_CONNECTION_LIMIT_DEFAULT = 8; +constexpr int HTTP_CONNECTION_LIMIT_MIN = 1; +constexpr int HTTP_CONNECTION_LIMIT_MAX = 256; // Pipelining limits -const long HTTP_PIPELINING_DEFAULT = 0L; -const long HTTP_PIPELINING_MAX = 20L; +constexpr long HTTP_PIPELINING_DEFAULT = 0L; +constexpr long HTTP_PIPELINING_MAX = 20L; // Miscellaneous defaults -const bool HTTP_USE_RETRY_AFTER_DEFAULT = true; -const long HTTP_THROTTLE_RATE_DEFAULT = 0L; +constexpr bool HTTP_USE_RETRY_AFTER_DEFAULT = true; +constexpr long HTTP_THROTTLE_RATE_DEFAULT = 0L; // Tuning parameters // Time worker thread sleeps after a pass through the // request, ready and active queues. -const int HTTP_SERVICE_LOOP_SLEEP_NORMAL_MS = 2; +constexpr int HTTP_SERVICE_LOOP_SLEEP_NORMAL_MS = 2; // Block allocation size (a tuning parameter) is found // in bufferarray.h. diff --git a/indra/llcorehttp/_httplibcurl.cpp b/indra/llcorehttp/_httplibcurl.cpp index e646271c84..6a15f08011 100644 --- a/indra/llcorehttp/_httplibcurl.cpp +++ b/indra/llcorehttp/_httplibcurl.cpp @@ -88,7 +88,7 @@ void HttpLibcurl::shutdown() if (mMultiHandles) { - for (int policy_class(0); policy_class < mPolicyCount; ++policy_class) + for (unsigned int policy_class(0); policy_class < mPolicyCount; ++policy_class) { if (mMultiHandles[policy_class]) { @@ -122,7 +122,7 @@ void HttpLibcurl::start(int policy_count) mActiveHandles = new int [mPolicyCount]; mDirtyPolicy = new bool [mPolicyCount]; - for (int policy_class(0); policy_class < mPolicyCount; ++policy_class) + for (unsigned int policy_class(0); policy_class < mPolicyCount; ++policy_class) { if (NULL == (mMultiHandles[policy_class] = curl_multi_init())) { @@ -148,7 +148,7 @@ HttpService::ELoopSpeed HttpLibcurl::processTransport() HttpService::ELoopSpeed ret(HttpService::REQUEST_SLEEP); // Give libcurl some cycles to do I/O & callbacks - for (int policy_class(0); policy_class < mPolicyCount; ++policy_class) + for (unsigned int policy_class(0); policy_class < mPolicyCount; ++policy_class) { if (! mMultiHandles[policy_class]) { @@ -442,18 +442,18 @@ bool HttpLibcurl::completeRequest(CURLM * multi_handle, CURL * handle, CURLcode int HttpLibcurl::getActiveCount() const { - return mActiveOps.size(); + return static_cast<int>(mActiveOps.size()); } -int HttpLibcurl::getActiveCountInClass(int policy_class) const +int HttpLibcurl::getActiveCountInClass(unsigned int policy_class) const { llassert_always(policy_class < mPolicyCount); return mActiveHandles ? mActiveHandles[policy_class] : 0; } -void HttpLibcurl::policyUpdated(int policy_class) +void HttpLibcurl::policyUpdated(unsigned int policy_class) { LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; if (policy_class < 0 || policy_class >= mPolicyCount || ! mMultiHandles) diff --git a/indra/llcorehttp/_httplibcurl.h b/indra/llcorehttp/_httplibcurl.h index a1b537d354..3631965837 100644 --- a/indra/llcorehttp/_httplibcurl.h +++ b/indra/llcorehttp/_httplibcurl.h @@ -107,7 +107,7 @@ public: /// /// Threading: called by worker thread. int getActiveCount() const; - int getActiveCountInClass(int policy_class) const; + int getActiveCountInClass(unsigned int policy_class) const; /// Attempt to cancel a request identified by handle. /// @@ -124,7 +124,7 @@ public: /// initialization and dynamic option setting. /// /// Threading: called by worker thread. - void policyUpdated(int policy_class); + void policyUpdated(unsigned int policy_class); /// Allocate a curl handle for caller. May be freed using /// either the freeHandle() method or calling curl_easy_cleanup() @@ -211,7 +211,7 @@ protected: HttpService * mService; // Simple reference, not owner HandleCache mHandleCache; // Handle allocator, owner active_set_t mActiveOps; - int mPolicyCount; + unsigned int mPolicyCount; CURLM ** mMultiHandles; // One handle per policy class int * mActiveHandles; // Active count per policy class bool * mDirtyPolicy; // Dirty policy update waiting for stall (per pc) diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 5165a6eb62..6186e7a308 100644 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -267,7 +267,7 @@ void HttpOpRequest::visitNotifier(HttpRequest * request) if (mReplyOffset || mReplyLength) { // Got an explicit offset/length in response - response->setRange(mReplyOffset, mReplyLength, mReplyFullLength); + response->setRange(mReplyOffset, static_cast<unsigned int>(mReplyLength), static_cast<unsigned int>(mReplyFullLength)); } response->setContentType(mReplyConType); response->setRetries(mPolicyRetries, mPolicy503Retries); @@ -328,7 +328,7 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id, LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; setupCommon(policy_id, url, NULL, options, headers); mReqMethod = HOR_GET; - mReqOffset = offset; + mReqOffset = static_cast<off_t>(offset); mReqLength = len; if (offset || len) { @@ -607,7 +607,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) long data_size(0); if (mReqBody) { - data_size = mReqBody->size(); + data_size = static_cast<long>(mReqBody->size()); } check_curl_easy_setopt(mCurlHandle, CURLOPT_POSTFIELDS, static_cast<void *>(NULL)); check_curl_easy_setopt(mCurlHandle, CURLOPT_POSTFIELDSIZE, data_size); @@ -618,13 +618,14 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) case HOR_PATCH: check_curl_easy_setopt(mCurlHandle, CURLOPT_CUSTOMREQUEST, "PATCH"); // fall through. The rest is the same as PUT + [[fallthrough]]; case HOR_PUT: { check_curl_easy_setopt(mCurlHandle, CURLOPT_UPLOAD, 1); long data_size(0); if (mReqBody) { - data_size = mReqBody->size(); + data_size = static_cast<long>(mReqBody->size()); } check_curl_easy_setopt(mCurlHandle, CURLOPT_INFILESIZE, data_size); mCurlHeaders = curl_slist_append(mCurlHeaders, "Expect:"); diff --git a/indra/llcorehttp/_httppolicy.cpp b/indra/llcorehttp/_httppolicy.cpp index 704c8abb93..a39d2f21a9 100644 --- a/indra/llcorehttp/_httppolicy.cpp +++ b/indra/llcorehttp/_httppolicy.cpp @@ -98,7 +98,7 @@ HttpPolicy::~HttpPolicy() HttpRequest::policy_t HttpPolicy::createPolicyClass() { - const HttpRequest::policy_t policy_class(mClasses.size()); + const HttpRequest::policy_t policy_class(static_cast<HttpRequest::policy_t>(mClasses.size())); if (policy_class >= HTTP_POLICY_CLASS_LIMIT) { return HttpRequest::INVALID_POLICY_ID; @@ -432,8 +432,8 @@ int HttpPolicy::getReadyCount(HttpRequest::policy_t policy_class) const { if (policy_class < mClasses.size()) { - return (mClasses[policy_class]->mReadyQueue.size() - + mClasses[policy_class]->mRetryQueue.size()); + return static_cast<int>((mClasses[policy_class]->mReadyQueue.size() + + mClasses[policy_class]->mRetryQueue.size())); } return 0; } diff --git a/indra/llcorehttp/_httpservice.cpp b/indra/llcorehttp/_httpservice.cpp index d543512ec4..5880fb7e87 100644 --- a/indra/llcorehttp/_httpservice.cpp +++ b/indra/llcorehttp/_httpservice.cpp @@ -317,7 +317,7 @@ void HttpService::threadRun(LLCoreInt::HttpThread * thread) } catch (std::bad_alloc&) { - LLMemory::logMemoryInfo(TRUE); + LLMemory::logMemoryInfo(true); //output possible call stacks to log file. LLError::LLUserWarningMsg::showOutOfMemory(); diff --git a/indra/llcorehttp/bufferarray.cpp b/indra/llcorehttp/bufferarray.cpp index 50a8d461a7..6b33661d8f 100644 --- a/indra/llcorehttp/bufferarray.cpp +++ b/indra/llcorehttp/bufferarray.cpp @@ -149,7 +149,7 @@ size_t BufferArray::append(const void * src, size_t len) } catch (std::bad_alloc&) { - LLMemory::logMemoryInfo(TRUE); + LLMemory::logMemoryInfo(true); //output possible call stacks to log file. LLError::LLCallStacks::print(); diff --git a/indra/llcorehttp/bufferarray.h b/indra/llcorehttp/bufferarray.h index 0269d1785e..5105dbc4f7 100644 --- a/indra/llcorehttp/bufferarray.h +++ b/indra/llcorehttp/bufferarray.h @@ -30,7 +30,6 @@ #include <cstdlib> #include <vector> -#include "boost/intrusive_ptr.hpp" #include "_refcounted.h" diff --git a/indra/llcorehttp/examples/http_texture_load.cpp b/indra/llcorehttp/examples/http_texture_load.cpp index 4d1e52b766..72e0c29a24 100644 --- a/indra/llcorehttp/examples/http_texture_load.cpp +++ b/indra/llcorehttp/examples/http_texture_load.cpp @@ -24,6 +24,8 @@ * $/LicenseInfo$ */ +#include "linden_common.h" + #include <iostream> #include <cstdio> #include <cstdlib> @@ -33,8 +35,6 @@ #include <pthread.h> #endif -#include "linden_common.h" - #include "httpcommon.h" #include "httprequest.h" #include "httphandler.h" @@ -519,7 +519,7 @@ void WorkingSet::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * r { // More success LLCore::BufferArray * data(response->getBody()); - mByteCount += data ? data->size() : 0; + mByteCount += data ? static_cast<long>(data->size()) : 0L; ++mSuccesses; } else @@ -602,7 +602,7 @@ void WorkingSet::loadAssetUuids(FILE * in) mAssets.push_back(asset); } } - mRemaining = mLimit = mAssets.size(); + mRemaining = mLimit = static_cast<int>(mAssets.size()); } diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 0a1c5ed101..511a17e000 100644 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -189,13 +189,9 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces #include "llsd.h" -#include "boost/intrusive_ptr.hpp" -#include "boost/shared_ptr.hpp" -#include "boost/weak_ptr.hpp" -#include "boost/function.hpp" -#include "boost/noncopyable.hpp" #include <string> #include <curl/curl.h> +#include "boost/noncopyable.hpp" namespace LLCore { diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 216d407deb..2aaf71f8a4 100644 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -489,6 +489,7 @@ HttpStatus HttpRequest::createService() HttpRequestQueue::init(); HttpRequestQueue * rq = HttpRequestQueue::instanceOf(); HttpService::init(rq); + HTTPStats::createInstance(); has_inited = true; } @@ -502,6 +503,7 @@ HttpStatus HttpRequest::destroyService() if (has_inited) { + HTTPStats::deleteSingleton(); HttpService::term(); HttpRequestQueue::term(); has_inited = false; diff --git a/indra/llcorehttp/httpstats.h b/indra/llcorehttp/httpstats.h index e1387d9df5..5c0f26d34e 100644 --- a/indra/llcorehttp/httpstats.h +++ b/indra/llcorehttp/httpstats.h @@ -35,24 +35,24 @@ namespace LLCore { - class HTTPStats : public LLSingleton<HTTPStats> + class HTTPStats final : public LLSimpleton<HTTPStats> { - LLSINGLETON(HTTPStats); - virtual ~HTTPStats(); - public: + HTTPStats(); + ~HTTPStats(); + void resetStats(); typedef LLStatsAccumulator StatsAccumulator; void recordDataDown(size_t bytes) { - mDataDown.push(bytes); + mDataDown.push((F32)bytes); } void recordDataUp(size_t bytes) { - mDataUp.push(bytes); + mDataUp.push((F32)bytes); } void recordHTTPRequest() { ++mRequests; } diff --git a/indra/llcorehttp/tests/llcorehttp_test.cpp b/indra/llcorehttp/tests/llcorehttp_test.cpp index c0cc2c8030..8a788e5a93 100755 --- a/indra/llcorehttp/tests/llcorehttp_test.cpp +++ b/indra/llcorehttp/tests/llcorehttp_test.cpp @@ -43,9 +43,12 @@ #include "test_httpoperation.hpp" // As of 2019-06-28, test_httprequest.hpp consistently crashes on Mac Release // builds for reasons not yet diagnosed. -#if ! (LL_DARWIN && LL_RELEASE) +// On Linux too, this is likely to badly handling (p)thread creation and not waiting +// for threads to properly shutdown +#if LL_WINDOWS #include "test_httprequest.hpp" #endif + #include "test_httpheaders.hpp" #include "test_httprequestqueue.hpp" #include "_httpservice.h" diff --git a/indra/llcorehttp/tests/test_httpoperation.hpp b/indra/llcorehttp/tests/test_httpoperation.hpp index 6778c3440b..361091c7b2 100644 --- a/indra/llcorehttp/tests/test_httpoperation.hpp +++ b/indra/llcorehttp/tests/test_httpoperation.hpp @@ -92,7 +92,7 @@ namespace tut op->setReplyPath(LLCore::HttpOperation::HttpReplyQueuePtr_t(), h1); // Check ref count - ensure(op.unique() == 1); + ensure(op.use_count() == 1); // release the reference, releasing the operation but // not the handlers. |