From 107b9bcb70e785c2d12515e38b8b296eea7ab8d8 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 20 May 2015 10:56:09 -0400 Subject: MAINT-5232: Introduce SUBSYSTEM_CLEANUP() macro and use it for existing LLSomeClass::cleanupClass() calls. This logs the fact of making the call, as well as making it. --- indra/llcorehttp/tests/llcorehttp_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llcorehttp') diff --git a/indra/llcorehttp/tests/llcorehttp_test.cpp b/indra/llcorehttp/tests/llcorehttp_test.cpp index e863ddd13f..19a20e663c 100755 --- a/indra/llcorehttp/tests/llcorehttp_test.cpp +++ b/indra/llcorehttp/tests/llcorehttp_test.cpp @@ -46,6 +46,7 @@ #include "test_httprequestqueue.hpp" #include "llproxy.h" +#include "llcleanup.h" unsigned long ssl_thread_id_callback(void); void ssl_locking_callback(int mode, int type, const char * file, int line); @@ -101,7 +102,7 @@ void init_curl() void term_curl() { - LLProxy::cleanupClass(); + SUBSYSTEM_CLEANUP(LLProxy); CRYPTO_set_locking_callback(NULL); for (int i(0); i < ssl_mutex_count; ++i) -- cgit v1.2.3 From 1a34afb1cc6464c030927a99737980bea7b8857a Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 23 Sep 2016 06:16:46 -0700 Subject: MAINT-5232: Try workaround for dubious llcorehttp mem usage test. --- indra/llcorehttp/tests/test_httprequest.hpp | 205 +++++++++++++++------------- 1 file changed, 109 insertions(+), 96 deletions(-) (limited to 'indra/llcorehttp') diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index 463e55dd7e..f9b57f5544 100644 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -1455,113 +1455,126 @@ void HttpRequestTestObjectType::test<14>() set_test_name("HttpRequest GET timeout"); - // Handler can be stack-allocated *if* there are no dangling - // references to it after completion of this method. - // Create before memory record as the string copy will bump numbers. - TestHandler2 handler(this, "handler"); - LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); - std::string url_base(get_base_url() + "/sleep/"); // path to a 30-second sleep - - // record the total amount of dynamically allocated memory - mMemTotal = GetMemTotal(); - mHandlerCalls = 0; - - HttpRequest * req = NULL; - HttpOptions::ptr_t opts; - - try + // The before-and-after memory test for this can fail since GetMemTotal() + // counts EVERYTHING, including memory used outside llcorehttp. Rider + // suggests running the whole test twice: the first time to fully allocate + // whatever is consumed by other subsystems, the second time to try the + // before-and-after check. + for (unsigned short attempt = 0; attempt < 2; ++attempt) { - // Get singletons created - HttpRequest::createService(); - - // Start threading early so that thread memory is invariant - // over the test. - HttpRequest::startThread(); + // Handler can be stack-allocated *if* there are no dangling + // references to it after completion of this method. + // Create before memory record as the string copy will bump numbers. + TestHandler2 handler(this, "handler"); + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + std::string url_base(get_base_url() + "/sleep/"); // path to a 30-second sleep + + // record the total amount of dynamically allocated memory + mMemTotal = GetMemTotal(); + mHandlerCalls = 0; - // create a new ref counted object with an implicit reference - req = new HttpRequest(); - ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); + HttpRequest * req = NULL; + HttpOptions::ptr_t opts; - opts = HttpOptions::ptr_t(new HttpOptions); - opts->setRetries(0); // Don't retry - opts->setTimeout(2); - - // Issue a GET that sleeps - mStatus = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_OPERATION_TIMEDOUT); - HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, - 0U, - url_base, - 0, - 0, - opts, - HttpHeaders::ptr_t(), - handlerp); - ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); - - // Run the notification pump. - int count(0); - int limit(LOOP_COUNT_LONG); - while (count++ < limit && mHandlerCalls < 1) + try { - req->update(1000000); - usleep(LOOP_SLEEP_INTERVAL); - } - ensure("Request executed in reasonable time", count < limit); - ensure("One handler invocation for request", mHandlerCalls == 1); + // Get singletons created + HttpRequest::createService(); - // Okay, request a shutdown of the servicing thread - mStatus = HttpStatus(); - handle = req->requestStopThread(handlerp); - ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); - - // Run the notification pump again - count = 0; - limit = LOOP_COUNT_LONG; - while (count++ < limit && mHandlerCalls < 2) - { - req->update(1000000); - usleep(LOOP_SLEEP_INTERVAL); - } - ensure("Second request executed in reasonable time", count < limit); - ensure("Second handler invocation", mHandlerCalls == 2); + // Start threading early so that thread memory is invariant + // over the test. + HttpRequest::startThread(); - // See that we actually shutdown the thread - count = 0; - limit = LOOP_COUNT_SHORT; - while (count++ < limit && ! HttpService::isStopped()) - { - usleep(LOOP_SLEEP_INTERVAL); - } - ensure("Thread actually stopped running", HttpService::isStopped()); + // create a new ref counted object with an implicit reference + req = new HttpRequest(); + ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - // release options - opts.reset(); - - // release the request object - delete req; - req = NULL; + opts = HttpOptions::ptr_t(new HttpOptions); + opts->setRetries(0); // Don't retry + opts->setTimeout(2); - // Shut down service - HttpRequest::destroyService(); - - ensure("Two handler calls on the way out", 2 == mHandlerCalls); + // Issue a GET that sleeps + mStatus = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_OPERATION_TIMEDOUT); + HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, + 0U, + url_base, + 0, + 0, + opts, + HttpHeaders::ptr_t(), + handlerp); + ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); + + // Run the notification pump. + int count(0); + int limit(LOOP_COUNT_LONG); + while (count++ < limit && mHandlerCalls < 1) + { + req->update(1000000); + usleep(LOOP_SLEEP_INTERVAL); + } + ensure("Request executed in reasonable time", count < limit); + ensure("One handler invocation for request", mHandlerCalls == 1); + + // Okay, request a shutdown of the servicing thread + mStatus = HttpStatus(); + handle = req->requestStopThread(handlerp); + ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); + + // Run the notification pump again + count = 0; + limit = LOOP_COUNT_LONG; + while (count++ < limit && mHandlerCalls < 2) + { + req->update(1000000); + usleep(LOOP_SLEEP_INTERVAL); + } + ensure("Second request executed in reasonable time", count < limit); + ensure("Second handler invocation", mHandlerCalls == 2); + + // See that we actually shutdown the thread + count = 0; + limit = LOOP_COUNT_SHORT; + while (count++ < limit && ! HttpService::isStopped()) + { + usleep(LOOP_SLEEP_INTERVAL); + } + ensure("Thread actually stopped running", HttpService::isStopped()); + + // release options + opts.reset(); + + // release the request object + delete req; + req = NULL; + + // Shut down service + HttpRequest::destroyService(); + + ensure("Two handler calls on the way out", 2 == mHandlerCalls); #if defined(WIN32) - // Can only do this memory test on Windows. On other platforms, - // the LL logging system holds on to memory and produces what looks - // like memory leaks... - - // printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal()); - ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); + // Can only do this memory test on Windows. On other platforms, + // the LL logging system holds on to memory and produces what looks + // like memory leaks... + + // don't check the first time around this loop, see comment at top + // of test + if (attempt) + { + // printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal()); + ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); + } #endif - } - catch (...) - { - stop_thread(req); - opts.reset(); - delete req; - HttpRequest::destroyService(); - throw; + } + catch (...) + { + stop_thread(req); + opts.reset(); + delete req; + HttpRequest::destroyService(); + throw; + } } } -- cgit v1.2.3 From acbee7ffab3759fcd87e3f3be060dac8cf326b25 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 27 Sep 2016 10:36:14 -0400 Subject: MAINT-5232: Give up on running mem test twice: doesn't work --- indra/llcorehttp/tests/test_httprequest.hpp | 193 +++++++++++++--------------- 1 file changed, 90 insertions(+), 103 deletions(-) (limited to 'indra/llcorehttp') diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index f9b57f5544..b0169bf755 100644 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -1455,126 +1455,113 @@ void HttpRequestTestObjectType::test<14>() set_test_name("HttpRequest GET timeout"); - // The before-and-after memory test for this can fail since GetMemTotal() - // counts EVERYTHING, including memory used outside llcorehttp. Rider - // suggests running the whole test twice: the first time to fully allocate - // whatever is consumed by other subsystems, the second time to try the - // before-and-after check. - for (unsigned short attempt = 0; attempt < 2; ++attempt) + // Handler can be stack-allocated *if* there are no dangling + // references to it after completion of this method. + // Create before memory record as the string copy will bump numbers. + TestHandler2 handler(this, "handler"); + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + std::string url_base(get_base_url() + "/sleep/"); // path to a 30-second sleep + + // record the total amount of dynamically allocated memory + mMemTotal = GetMemTotal(); + mHandlerCalls = 0; + + HttpRequest * req = NULL; + HttpOptions::ptr_t opts; + + try { - // Handler can be stack-allocated *if* there are no dangling - // references to it after completion of this method. - // Create before memory record as the string copy will bump numbers. - TestHandler2 handler(this, "handler"); - LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); - std::string url_base(get_base_url() + "/sleep/"); // path to a 30-second sleep - - // record the total amount of dynamically allocated memory - mMemTotal = GetMemTotal(); - mHandlerCalls = 0; + // Get singletons created + HttpRequest::createService(); - HttpRequest * req = NULL; - HttpOptions::ptr_t opts; + // Start threading early so that thread memory is invariant + // over the test. + HttpRequest::startThread(); - try - { - // Get singletons created - HttpRequest::createService(); + // create a new ref counted object with an implicit reference + req = new HttpRequest(); + ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - // Start threading early so that thread memory is invariant - // over the test. - HttpRequest::startThread(); + opts = HttpOptions::ptr_t(new HttpOptions); + opts->setRetries(0); // Don't retry + opts->setTimeout(2); - // create a new ref counted object with an implicit reference - req = new HttpRequest(); - ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); + // Issue a GET that sleeps + mStatus = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_OPERATION_TIMEDOUT); + HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, + 0U, + url_base, + 0, + 0, + opts, + HttpHeaders::ptr_t(), + handlerp); + ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); - opts = HttpOptions::ptr_t(new HttpOptions); - opts->setRetries(0); // Don't retry - opts->setTimeout(2); + // Run the notification pump. + int count(0); + int limit(LOOP_COUNT_LONG); + while (count++ < limit && mHandlerCalls < 1) + { + req->update(1000000); + usleep(LOOP_SLEEP_INTERVAL); + } + ensure("Request executed in reasonable time", count < limit); + ensure("One handler invocation for request", mHandlerCalls == 1); - // Issue a GET that sleeps - mStatus = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_OPERATION_TIMEDOUT); - HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, - 0U, - url_base, - 0, - 0, - opts, - HttpHeaders::ptr_t(), - handlerp); - ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); + // Okay, request a shutdown of the servicing thread + mStatus = HttpStatus(); + handle = req->requestStopThread(handlerp); + ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); - // Run the notification pump. - int count(0); - int limit(LOOP_COUNT_LONG); - while (count++ < limit && mHandlerCalls < 1) - { - req->update(1000000); - usleep(LOOP_SLEEP_INTERVAL); - } - ensure("Request executed in reasonable time", count < limit); - ensure("One handler invocation for request", mHandlerCalls == 1); - - // Okay, request a shutdown of the servicing thread - mStatus = HttpStatus(); - handle = req->requestStopThread(handlerp); - ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); - - // Run the notification pump again - count = 0; - limit = LOOP_COUNT_LONG; - while (count++ < limit && mHandlerCalls < 2) - { - req->update(1000000); - usleep(LOOP_SLEEP_INTERVAL); - } - ensure("Second request executed in reasonable time", count < limit); - ensure("Second handler invocation", mHandlerCalls == 2); + // Run the notification pump again + count = 0; + limit = LOOP_COUNT_LONG; + while (count++ < limit && mHandlerCalls < 2) + { + req->update(1000000); + usleep(LOOP_SLEEP_INTERVAL); + } + ensure("Second request executed in reasonable time", count < limit); + ensure("Second handler invocation", mHandlerCalls == 2); - // See that we actually shutdown the thread - count = 0; - limit = LOOP_COUNT_SHORT; - while (count++ < limit && ! HttpService::isStopped()) - { - usleep(LOOP_SLEEP_INTERVAL); - } - ensure("Thread actually stopped running", HttpService::isStopped()); + // See that we actually shutdown the thread + count = 0; + limit = LOOP_COUNT_SHORT; + while (count++ < limit && ! HttpService::isStopped()) + { + usleep(LOOP_SLEEP_INTERVAL); + } + ensure("Thread actually stopped running", HttpService::isStopped()); - // release options - opts.reset(); + // release options + opts.reset(); - // release the request object - delete req; - req = NULL; + // release the request object + delete req; + req = NULL; - // Shut down service - HttpRequest::destroyService(); + // Shut down service + HttpRequest::destroyService(); - ensure("Two handler calls on the way out", 2 == mHandlerCalls); + ensure("Two handler calls on the way out", 2 == mHandlerCalls); #if defined(WIN32) - // Can only do this memory test on Windows. On other platforms, - // the LL logging system holds on to memory and produces what looks - // like memory leaks... + // Can only do this memory test on Windows. On other platforms, + // the LL logging system holds on to memory and produces what looks + // like memory leaks... - // don't check the first time around this loop, see comment at top - // of test - if (attempt) - { - // printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal()); - ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); - } + // printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal()); + ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); #endif - } - catch (...) - { - stop_thread(req); - opts.reset(); - delete req; - HttpRequest::destroyService(); - throw; - } + } + catch (...) + { + stop_thread(req); + opts.reset(); + delete req; + HttpRequest::destroyService(); + throw; } } -- cgit v1.2.3 From f4ecfd9cb99703bd3d11864f069c67f38776c0d7 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 27 Sep 2016 10:41:24 -0400 Subject: MAINT-5232: Disable unrealistic failing checks on GetMemTotal(). --- indra/llcorehttp/tests/test_httprequest.hpp | 31 +++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'indra/llcorehttp') diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index b0169bf755..6cd7960ecd 100644 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -729,7 +729,7 @@ void HttpRequestTestObjectType::test<7>() #if 0 // defined(WIN32) // Can't do this on any platform anymore, the LL logging system holds // on to memory and produces what looks like memory leaks... - + // printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal()); ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); #endif @@ -1546,10 +1546,9 @@ void HttpRequestTestObjectType::test<14>() ensure("Two handler calls on the way out", 2 == mHandlerCalls); -#if defined(WIN32) - // Can only do this memory test on Windows. On other platforms, - // the LL logging system holds on to memory and produces what looks - // like memory leaks... +#if 0 // defined(WIN32) + // Can't do this on any platform anymore, the LL logging system holds + // on to memory and produces what looks like memory leaks... // printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal()); ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); @@ -3065,12 +3064,11 @@ void HttpRequestTestObjectType::test<22>() // Shut down service HttpRequest::destroyService(); - -#if defined(WIN32) - // Can only do this memory test on Windows. On other platforms, - // the LL logging system holds on to memory and produces what looks - // like memory leaks... - + +#if 0 // defined(WIN32) + // Can't do this on any platform anymore, the LL logging system holds + // on to memory and produces what looks like memory leaks... + // printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal()); ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); #endif @@ -3195,12 +3193,11 @@ void HttpRequestTestObjectType::test<23>() // Shut down service HttpRequest::destroyService(); - -#if defined(WIN32) - // Can only do this memory test on Windows. On other platforms, - // the LL logging system holds on to memory and produces what looks - // like memory leaks... - + +#if 0 // defined(WIN32) + // Can't do this on any platform anymore, the LL logging system holds + // on to memory and produces what looks like memory leaks... + // printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal()); ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); #endif -- cgit v1.2.3 From d80145bf0f37d19ca10e78a9da00baf9c5c034e7 Mon Sep 17 00:00:00 2001 From: "nat@linux-build-phx8.lindenlab.com" Date: Tue, 27 Sep 2016 16:28:16 +0000 Subject: MAINT-5232: Ensure BOOST_SYSTEM_LIBRARY follows BOOST_THREAD_LIBRARY. In recent versions of Boost, BOOST_THREAD_LIBRARY depends on BOOST_SYSTEM_LIBRARY. In llcorehttp/CMakeLists.txt, these were incorrectly ordered for Linux. Somewhat oddly, that appears to have caused Linux link errors even in llmath. Fix at least this problem. --- indra/llcorehttp/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/llcorehttp') diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt index 0bb0348d26..b03ee6eeda 100644 --- a/indra/llcorehttp/CMakeLists.txt +++ b/indra/llcorehttp/CMakeLists.txt @@ -93,6 +93,7 @@ target_link_libraries( ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARIES} ${BOOST_THREAD_LIBRARY} + ${BOOST_SYSTEM_LIBRARY} ) # tests @@ -129,8 +130,8 @@ if (LL_TESTS) ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARIES} - ${BOOST_SYSTEM_LIBRARY} ${BOOST_THREAD_LIBRARY} + ${BOOST_SYSTEM_LIBRARY} ) # If http_proxy is in the current environment (e.g. to fetch s3-proxy @@ -197,8 +198,8 @@ endif (DARWIN) ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARIES} - ${BOOST_SYSTEM_LIBRARY} ${BOOST_THREAD_LIBRARY} + ${BOOST_SYSTEM_LIBRARY} ) add_executable(http_texture_load -- cgit v1.2.3