From 225612ea77b843e58e11ccb00165155cc907ae1b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 18 May 2015 11:48:50 -0700 Subject: Updater to coroutines. --- indra/viewer_components/updater/CMakeLists.txt | 3 + .../viewer_components/updater/llupdatechecker.cpp | 88 +++++++-------- indra/viewer_components/updater/llupdatechecker.h | 121 ++++++++++----------- 3 files changed, 104 insertions(+), 108 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 61fd4220e0..2e284bf993 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -9,12 +9,14 @@ endif(LL_TESTS) include(CMakeCopyIfDifferent) include(CURL) include(LLCommon) +include(LLCoreHttp) include(LLMessage) include(LLPlugin) include(LLVFS) include_directories( ${LLCOMMON_INCLUDE_DIRS} + ${LLCOREHTTP_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLPLUGIN_INCLUDE_DIRS} ${LLVFS_INCLUDE_DIRS} @@ -59,6 +61,7 @@ add_library(llupdaterservice target_link_libraries(llupdaterservice ${LLCOMMON_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLPLUGIN_LIBRARIES} ${LLVFS_LIBRARIES} diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index 8da4f88905..caeab35999 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -30,6 +30,7 @@ #include "llsd.h" #include "llupdatechecker.h" #include "lluri.h" +#include "llcorehttputil.h" #if LL_DARWIN #include #endif @@ -53,15 +54,12 @@ public: // LLUpdateChecker //----------------------------------------------------------------------------- - - LLUpdateChecker::LLUpdateChecker(LLUpdateChecker::Client & client): mImplementation(new LLUpdateChecker::Implementation(client)) { ; // No op. } - void LLUpdateChecker::checkVersion(std::string const & urlBase, std::string const & channel, std::string const & version, @@ -74,11 +72,8 @@ void LLUpdateChecker::checkVersion(std::string const & urlBase, } - // LLUpdateChecker::Implementation //----------------------------------------------------------------------------- - - const char * LLUpdateChecker::Implementation::sProtocolVersion = "v1.1"; @@ -121,57 +116,58 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, std::string checkUrl = buildUrl(urlBase, channel, version, platform, platform_version, uniqueid, willing_to_test); LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL; - - mHttpClient.get(checkUrl, this); - } - else - { - LL_WARNS("UpdaterService") << "attempting to restart a check when one is in progress; ignored" << LL_ENDL; - } -} -void LLUpdateChecker::Implementation::httpCompleted() -{ - mInProgress = false; + LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro", + boost::bind(&Implementation::checkVersionCoro, this, _1, checkUrl)); - S32 status = getStatus(); - const LLSD& content = getContent(); - const std::string& reason = getReason(); - if(status != 200) - { - std::string server_error; - if ( content.has("error_code") ) - { - server_error += content["error_code"].asString(); - } - if ( content.has("error_text") ) - { - server_error += server_error.empty() ? "" : ": "; - server_error += content["error_text"].asString(); - } - - LL_WARNS("UpdaterService") << "response error " << status - << " " << reason - << " (" << server_error << ")" - << LL_ENDL; - mClient.error(reason); } else { - mClient.response(content); + LL_WARNS("UpdaterService") << "attempting to restart a check when one is in progress; ignored" << LL_ENDL; } } - -void LLUpdateChecker::Implementation::httpFailure() +void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string &url) { - const std::string& reason = getReason(); - mInProgress = false; - LL_WARNS("UpdaterService") << "update check failed; " << reason << LL_ENDL; - mClient.error(reason); + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("checkVersionCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + mInProgress = false; + + if (status != LLCore::HttpStatus(HTTP_OK)) + { + std::string server_error; + if (result.has("error_code")) + { + server_error += result["error_code"].asString(); + } + if (result.has("error_text")) + { + server_error += server_error.empty() ? "" : ": "; + server_error += result["error_text"].asString(); + } + + LL_WARNS("UpdaterService") << "response error " << status.getStatus() + << " " << status.toString() + << " (" << server_error << ")" + << LL_ENDL; + mClient.error(status.toString()); + return; + } + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + mClient.response(result); } - std::string LLUpdateChecker::Implementation::buildUrl(std::string const & urlBase, std::string const & channel, std::string const & version, diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index 3163a6d53c..74af718a15 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -31,60 +31,27 @@ #include "llmd5.h" #include "llhttpclient.h" +#include "lleventcoro.h" +#include "llcoros.h" // // Implements asynchronous checking for updates. // class LLUpdateChecker { public: - class Client; - class Implementation: public LLHTTPClient::Responder - { - public: - Implementation(Client & client); - ~Implementation(); - void checkVersion(std::string const & urlBase, - std::string const & channel, - std::string const & version, - std::string const & platform, - std::string const & platform_version, - unsigned char uniqueid[MD5HEX_STR_SIZE], - bool willing_to_test - ); - - protected: - // Responder: - virtual void httpCompleted(); - virtual void httpFailure(); - - private: - static const char * sLegacyProtocolVersion; - static const char * sProtocolVersion; - const char* mProtocol; - - Client & mClient; - LLHTTPClient mHttpClient; - bool mInProgress; - std::string mVersion; - std::string mUrlBase; - std::string mChannel; - std::string mPlatform; - std::string mPlatformVersion; - unsigned char mUniqueId[MD5HEX_STR_SIZE]; - bool mWillingToTest; - - std::string buildUrl(std::string const & urlBase, - std::string const & channel, - std::string const & version, - std::string const & platform, - std::string const & platform_version, - unsigned char uniqueid[MD5HEX_STR_SIZE], - bool willing_to_test); - - LOG_CLASS(LLUpdateChecker::Implementation); - }; + // + // The client interface implemented by a requestor checking for an update. + // + class Client + { + public: + // An error occurred while checking for an update. + virtual void error(std::string const & message) = 0; + + // A successful response was received from the viewer version manager + virtual void response(LLSD const & content) = 0; + }; - // An exception that may be raised on check errors. class CheckError; @@ -100,25 +67,55 @@ public: bool willing_to_test); private: - LLPointer mImplementation; -}; + class Implementation + { + public: + typedef boost::shared_ptr ptr_t; + Implementation(Client & client); + ~Implementation(); + void checkVersion(std::string const & urlBase, + std::string const & channel, + std::string const & version, + std::string const & platform, + std::string const & platform_version, + unsigned char uniqueid[MD5HEX_STR_SIZE], + bool willing_to_test + ); -class LLURI; // From lluri.h + private: + static const char * sLegacyProtocolVersion; + static const char * sProtocolVersion; + const char* mProtocol; -// -// The client interface implemented by a requestor checking for an update. -// -class LLUpdateChecker::Client -{ -public: - // An error occurred while checking for an update. - virtual void error(std::string const & message) = 0; - - // A successful response was received from the viewer version manager - virtual void response(LLSD const & content) = 0; -}; + Client & mClient; + LLHTTPClient mHttpClient; + bool mInProgress; + std::string mVersion; + std::string mUrlBase; + std::string mChannel; + std::string mPlatform; + std::string mPlatformVersion; + unsigned char mUniqueId[MD5HEX_STR_SIZE]; + bool mWillingToTest; + + std::string buildUrl(std::string const & urlBase, + std::string const & channel, + std::string const & version, + std::string const & platform, + std::string const & platform_version, + unsigned char uniqueid[MD5HEX_STR_SIZE], + bool willing_to_test); + + void checkVersionCoro(LLCoros::self& self, std::string &url); + LOG_CLASS(LLUpdateChecker::Implementation); + }; + + + Implementation::ptr_t mImplementation; + //LLPointer mImplementation; +}; #endif -- cgit v1.2.3 From 46a86ddb7a59c2b82135c66e8855cfa84d25bf25 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 18 May 2015 13:39:48 -0700 Subject: Remove an unused variable from the updatechecker. --- indra/viewer_components/updater/llupdatechecker.h | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index 74af718a15..0f9be14524 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -90,7 +90,6 @@ private: const char* mProtocol; Client & mClient; - LLHTTPClient mHttpClient; bool mInProgress; std::string mVersion; std::string mUrlBase; -- cgit v1.2.3 From a4741cecb2112f418c1d98ca63a261e707a856c3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 18 May 2015 16:18:07 -0700 Subject: Changed Avatar picker to use coroutine for find. Fixed a stray reference (&) on URL that had crept into some coroutine definitions. --- indra/viewer_components/updater/llupdatechecker.cpp | 2 +- indra/viewer_components/updater/llupdatechecker.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index caeab35999..e5d7d345cb 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -127,7 +127,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, } } -void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string &url) +void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index 0f9be14524..09ed306ca7 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -107,7 +107,7 @@ private: unsigned char uniqueid[MD5HEX_STR_SIZE], bool willing_to_test); - void checkVersionCoro(LLCoros::self& self, std::string &url); + void checkVersionCoro(LLCoros::self& self, std::string url); LOG_CLASS(LLUpdateChecker::Implementation); }; -- cgit v1.2.3 From 0d3fb07bfa205b65f242ef2b761e827ff30e42fe Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 3 Jun 2015 16:04:40 -0700 Subject: Remove vestigial httpclient.h include from files that no longer need it. --- indra/viewer_components/updater/llupdatechecker.cpp | 1 - indra/viewer_components/updater/llupdatechecker.h | 1 - 2 files changed, 2 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index e5d7d345cb..29cb238892 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -26,7 +26,6 @@ #include "linden_common.h" #include #include -#include "llhttpclient.h" #include "llsd.h" #include "llupdatechecker.h" #include "lluri.h" diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index 09ed306ca7..e5050bb952 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -30,7 +30,6 @@ #include #include "llmd5.h" -#include "llhttpclient.h" #include "lleventcoro.h" #include "llcoros.h" -- cgit v1.2.3 From 4a4470af3210153e0909eb75d51de461d14a3128 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 17 Jun 2015 13:53:28 -0700 Subject: Coding policy fixes --- indra/viewer_components/updater/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 2e284bf993..53e309290f 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -16,7 +16,7 @@ include(LLVFS) include_directories( ${LLCOMMON_INCLUDE_DIRS} - ${LLCOREHTTP_INCLUDE_DIRS} + ${LLCOREHTTP_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLPLUGIN_INCLUDE_DIRS} ${LLVFS_INCLUDE_DIRS} @@ -61,7 +61,7 @@ add_library(llupdaterservice target_link_libraries(llupdaterservice ${LLCOMMON_LIBRARIES} - ${LLCOREHTTP_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLMESSAGE_LIBRARIES} ${LLPLUGIN_LIBRARIES} ${LLVFS_LIBRARIES} -- cgit v1.2.3 From b262ded7e0cf21314524bf702b0e4fe28a3c3060 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 1 Jul 2015 18:33:29 -0400 Subject: MAINT-5351: Remove 'self' parameter from coroutine functions. lleventcoro_test.cpp runs clean (as modified for new API), and all the rest builds clean, but the resulting viewer is as yet untested. --- indra/viewer_components/updater/llupdatechecker.cpp | 6 +++--- indra/viewer_components/updater/llupdatechecker.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index 29cb238892..e889f83aa9 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -117,7 +117,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL; LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro", - boost::bind(&Implementation::checkVersionCoro, this, _1, checkUrl)); + boost::bind(&Implementation::checkVersionCoro, this, checkUrl)); } else @@ -126,7 +126,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, } } -void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string url) +void LLUpdateChecker::Implementation::checkVersionCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -135,7 +135,7 @@ void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std: LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index e5050bb952..d10ea4cf42 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -106,7 +106,7 @@ private: unsigned char uniqueid[MD5HEX_STR_SIZE], bool willing_to_test); - void checkVersionCoro(LLCoros::self& self, std::string url); + void checkVersionCoro(std::string url); LOG_CLASS(LLUpdateChecker::Implementation); }; -- cgit v1.2.3 From 247eb0c9c3418c10be8f2a0e3c8116758efa702f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Jul 2015 19:41:27 +0100 Subject: Backout selfles merge 738255dbbfd679d9e615baab3398e5e345bbb3c5 --- indra/viewer_components/updater/llupdatechecker.cpp | 6 +++--- indra/viewer_components/updater/llupdatechecker.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index e889f83aa9..29cb238892 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -117,7 +117,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL; LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro", - boost::bind(&Implementation::checkVersionCoro, this, checkUrl)); + boost::bind(&Implementation::checkVersionCoro, this, _1, checkUrl)); } else @@ -126,7 +126,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, } } -void LLUpdateChecker::Implementation::checkVersionCoro(std::string url) +void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -135,7 +135,7 @@ void LLUpdateChecker::Implementation::checkVersionCoro(std::string url) LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index d10ea4cf42..e5050bb952 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -106,7 +106,7 @@ private: unsigned char uniqueid[MD5HEX_STR_SIZE], bool willing_to_test); - void checkVersionCoro(std::string url); + void checkVersionCoro(LLCoros::self& self, std::string url); LOG_CLASS(LLUpdateChecker::Implementation); }; -- cgit v1.2.3 From efa9a0f99c17b2b937120bcad6e3d45944122ed9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 Jul 2015 19:30:10 -0400 Subject: Backed out changeset bab1000e1b2d: restore 'selfless' changes --- indra/viewer_components/updater/llupdatechecker.cpp | 6 +++--- indra/viewer_components/updater/llupdatechecker.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index 29cb238892..e889f83aa9 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -117,7 +117,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, LL_INFOS("UpdaterService") << "checking for updates at " << checkUrl << LL_ENDL; LLCoros::instance().launch("LLUpdateChecker::Implementation::checkVersionCoro", - boost::bind(&Implementation::checkVersionCoro, this, _1, checkUrl)); + boost::bind(&Implementation::checkVersionCoro, this, checkUrl)); } else @@ -126,7 +126,7 @@ void LLUpdateChecker::Implementation::checkVersion(std::string const & urlBase, } } -void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std::string url) +void LLUpdateChecker::Implementation::checkVersionCoro(std::string url) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -135,7 +135,7 @@ void LLUpdateChecker::Implementation::checkVersionCoro(LLCoros::self& self, std: LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); diff --git a/indra/viewer_components/updater/llupdatechecker.h b/indra/viewer_components/updater/llupdatechecker.h index e5050bb952..d10ea4cf42 100755 --- a/indra/viewer_components/updater/llupdatechecker.h +++ b/indra/viewer_components/updater/llupdatechecker.h @@ -106,7 +106,7 @@ private: unsigned char uniqueid[MD5HEX_STR_SIZE], bool willing_to_test); - void checkVersionCoro(LLCoros::self& self, std::string url); + void checkVersionCoro(std::string url); LOG_CLASS(LLUpdateChecker::Implementation); }; -- cgit v1.2.3 From 8e6bea61a9763703b89e1da220b9d67573f9fb7c Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sun, 12 Jul 2015 10:57:13 -0400 Subject: MAINT-5351: llupdaterservice_test now needs Boost System library. --- indra/viewer_components/updater/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 53e309290f..0d44334276 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -6,6 +6,7 @@ include(00-Common) if(LL_TESTS) include(LLAddBuildTest) endif(LL_TESTS) +include(Boost) include(CMakeCopyIfDifferent) include(CURL) include(LLCommon) @@ -72,14 +73,16 @@ if(LL_TESTS) llupdaterservice.cpp ) + +set_source_files_properties( + llupdaterservice.cpp + PROPERTIES + LL_TEST_ADDITIONAL_LIBRARIES "${BOOST_SYSTEM_LIBRARY}" # *NOTE:Mani - I was trying to use the preprocessor seam to mock out -# llifstream (and other) llcommon classes. I didn't work +# llifstream (and other) llcommon classes. It didn't work # because of the windows declspec(dllimport)attribute. -#set_source_files_properties( -# llupdaterservice.cpp -# PROPERTIES -# LL_TEST_ADDITIONAL_CFLAGS "-Dllifstream=llus_mock_llifstream" -# ) +# LL_TEST_ADDITIONAL_CFLAGS "-Dllifstream=llus_mock_llifstream" + ) LL_ADD_PROJECT_UNIT_TESTS(llupdaterservice "${llupdater_service_TEST_SOURCE_FILES}") endif(LL_TESTS) -- cgit v1.2.3 From d3c2ab581763586718bc0cd86d6935bb46dc9d10 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 19 Aug 2015 12:39:51 -0700 Subject: Be sure the correct include is included. --- indra/viewer_components/updater/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 0d44334276..48c065c2ed 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -62,8 +62,8 @@ add_library(llupdaterservice target_link_libraries(llupdaterservice ${LLCOMMON_LIBRARIES} - ${LLCOREHTTP_LIBRARIES} ${LLMESSAGE_LIBRARIES} + ${LLCOREHTTP_LIBRARIES} ${LLPLUGIN_LIBRARIES} ${LLVFS_LIBRARIES} ) -- cgit v1.2.3 From 907efc9cc9bcf4a935ed0e1bd17b19da2bb99dce Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 15 Sep 2015 17:01:26 -0700 Subject: MAINT-5507: Remove llcurl, move constant values and untilities to llcorehttp lib --- .../updater/llupdatedownloader.cpp | 54 ++++++++++------------ 1 file changed, 25 insertions(+), 29 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatedownloader.cpp b/indra/viewer_components/updater/llupdatedownloader.cpp index f868e5cc2c..53c729469b 100755 --- a/indra/viewer_components/updater/llupdatedownloader.cpp +++ b/indra/viewer_components/updater/llupdatedownloader.cpp @@ -26,7 +26,7 @@ #include "linden_common.h" #include "llupdatedownloader.h" - +#include "httpcommon.h" #include #include #include @@ -39,7 +39,6 @@ #include "llsdserialize.h" #include "llthread.h" #include "llupdaterservice.h" -#include "llcurl.h" class LLUpdateDownloader::Implementation: public LLThread @@ -65,7 +64,7 @@ private: curl_off_t mBandwidthLimit; bool mCancelled; LLUpdateDownloader::Client & mClient; - CURL * mCurl; + LLCore::LLHttp::CURL_ptr mCurl; LLSD mDownloadData; llofstream mDownloadStream; unsigned char mDownloadPercent; @@ -192,7 +191,7 @@ LLUpdateDownloader::Implementation::Implementation(LLUpdateDownloader::Client & mBandwidthLimit(0), mCancelled(false), mClient(client), - mCurl(0), + mCurl(), mDownloadPercent(0), mHeaderList(0) { @@ -212,10 +211,7 @@ LLUpdateDownloader::Implementation::~Implementation() { ; // No op. } - if(mCurl) - { - LLCurl::deleteEasyHandle(mCurl); - } + mCurl.reset(); } @@ -331,9 +327,9 @@ void LLUpdateDownloader::Implementation::setBandwidthLimit(U64 bytesPerSecond) { if((mBandwidthLimit != bytesPerSecond) && isDownloading() && !mDownloadData["required"].asBoolean()) { - llassert(mCurl != 0); + llassert(static_cast(mCurl)); mBandwidthLimit = bytesPerSecond; - CURLcode code = curl_easy_setopt(mCurl, CURLOPT_MAX_RECV_SPEED_LARGE, &mBandwidthLimit); + CURLcode code = curl_easy_setopt(mCurl.get(), CURLOPT_MAX_RECV_SPEED_LARGE, &mBandwidthLimit); if(code != CURLE_OK) { LL_WARNS("UpdaterService") << "unable to change dowload bandwidth" << LL_ENDL; @@ -416,7 +412,7 @@ int LLUpdateDownloader::Implementation::onProgress(double downloadSize, double b void LLUpdateDownloader::Implementation::run(void) { - CURLcode code = curl_easy_perform(mCurl); + CURLcode code = curl_easy_perform(mCurl.get()); mDownloadStream.close(); if(code == CURLE_OK) { @@ -460,36 +456,36 @@ void LLUpdateDownloader::Implementation::run(void) void LLUpdateDownloader::Implementation::initializeCurlGet(std::string const & url, bool processHeader) { - if(mCurl == 0) + if(!mCurl) { - mCurl = LLCurl::newEasyHandle(); + mCurl = LLCore::LLHttp::createEasyHandle(); } else { - curl_easy_reset(mCurl); + curl_easy_reset(mCurl.get()); } - if(mCurl == 0) + if(!mCurl) { throw DownloadError("failed to initialize curl"); } - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_NOSIGNAL, true)); - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_FOLLOWLOCATION, true)); - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_WRITEFUNCTION, &write_function)); - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_WRITEDATA, this)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_NOSIGNAL, true)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_FOLLOWLOCATION, true)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_WRITEFUNCTION, &write_function)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_WRITEDATA, this)); if(processHeader) { - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_HEADERFUNCTION, &header_function)); - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_HEADERDATA, this)); - } - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_HTTPGET, true)); - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_URL, url.c_str())); - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_PROGRESSFUNCTION, &progress_callback)); - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_PROGRESSDATA, this)); - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_NOPROGRESS, false)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_HEADERFUNCTION, &header_function)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_HEADERDATA, this)); + } + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_HTTPGET, true)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_URL, url.c_str())); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_PROGRESSFUNCTION, &progress_callback)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_PROGRESSDATA, this)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_NOPROGRESS, false)); // if it's a required update set the bandwidth limit to 0 (unlimited) curl_off_t limit = mDownloadData["required"].asBoolean() ? 0 : mBandwidthLimit; - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_MAX_RECV_SPEED_LARGE, limit)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_MAX_RECV_SPEED_LARGE, limit)); mDownloadPercent = 0; } @@ -511,7 +507,7 @@ void LLUpdateDownloader::Implementation::resumeDownloading(size_t startByte) { throw DownloadError("cannot add Range header"); } - throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_HTTPHEADER, mHeaderList)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_HTTPHEADER, mHeaderList)); mDownloadStream.open(mDownloadData["path"].asString().c_str(), std::ios_base::out | std::ios_base::binary | std::ios_base::app); -- cgit v1.2.3 From 75c6549fde060e974c90636685962ee373f94202 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 18 Sep 2015 11:39:22 -0700 Subject: Set consistent terminology for yield/wait -> suspend for coroutines. --- indra/viewer_components/updater/llupdatechecker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatechecker.cpp b/indra/viewer_components/updater/llupdatechecker.cpp index e889f83aa9..1bb5e95740 100755 --- a/indra/viewer_components/updater/llupdatechecker.cpp +++ b/indra/viewer_components/updater/llupdatechecker.cpp @@ -135,7 +135,7 @@ void LLUpdateChecker::Implementation::checkVersionCoro(std::string url) LL_INFOS("checkVersionCoro") << "Getting update information from " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(httpRequest, url); + LLSD result = httpAdapter->getAndSuspend(httpRequest, url); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From b98469bd7db06973e6058118551e500dc094d3c0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 18 Dec 2015 13:53:03 -0800 Subject: Disable unit test on Linux only --- indra/viewer_components/updater/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 48c065c2ed..7f866336d9 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -73,18 +73,23 @@ if(LL_TESTS) llupdaterservice.cpp ) +set(test_libs + ${LLCOMMON_LIBRARIES}) + set_source_files_properties( llupdaterservice.cpp PROPERTIES - LL_TEST_ADDITIONAL_LIBRARIES "${BOOST_SYSTEM_LIBRARY}" + LL_TEST_ADDITIONAL_LIBRARIES ${test_libs} # *NOTE:Mani - I was trying to use the preprocessor seam to mock out # llifstream (and other) llcommon classes. It didn't work # because of the windows declspec(dllimport)attribute. # LL_TEST_ADDITIONAL_CFLAGS "-Dllifstream=llus_mock_llifstream" ) - LL_ADD_PROJECT_UNIT_TESTS(llupdaterservice "${llupdater_service_TEST_SOURCE_FILES}") +if (NOT LINUX) + LL_ADD_PROJECT_UNIT_TESTS(llupdaterservice "${llupdater_service_TEST_SOURCE_FILES}" ${test_libs}) +endif (NOT LINUX) endif(LL_TESTS) set(UPDATER_INCLUDE_DIRS -- cgit v1.2.3 From 3edc3c5554965b947a8086c9f4f95a28b3a7aaa8 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 21 Dec 2015 14:26:41 -0800 Subject: CMake fixes for Linux build --- indra/viewer_components/updater/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/CMakeLists.txt b/indra/viewer_components/updater/CMakeLists.txt index 7f866336d9..73e18aacb3 100755 --- a/indra/viewer_components/updater/CMakeLists.txt +++ b/indra/viewer_components/updater/CMakeLists.txt @@ -69,13 +69,17 @@ target_link_libraries(llupdaterservice ) if(LL_TESTS) +if (NOT LINUX) SET(llupdater_service_TEST_SOURCE_FILES llupdaterservice.cpp ) set(test_libs - ${LLCOMMON_LIBRARIES}) - + ${LLCOMMON_LIBRARIES} + ${BOOST_COROUTINE_LIBRARY} + ${BOOST_CONTEXT_LIBRARY} + ${BOOST_THREAD_LIBRARY} + ${BOOST_SYSTEM_LIBRARY}) set_source_files_properties( llupdaterservice.cpp @@ -87,7 +91,6 @@ set_source_files_properties( # LL_TEST_ADDITIONAL_CFLAGS "-Dllifstream=llus_mock_llifstream" ) -if (NOT LINUX) LL_ADD_PROJECT_UNIT_TESTS(llupdaterservice "${llupdater_service_TEST_SOURCE_FILES}" ${test_libs}) endif (NOT LINUX) endif(LL_TESTS) -- cgit v1.2.3 From e307a46bdd6c42828e478126aac7a220c37e33b7 Mon Sep 17 00:00:00 2001 From: Drake Arconis Date: Thu, 25 Feb 2016 15:01:46 -0500 Subject: Update to modern curl progress reporting functionality in the update downloader --- .../updater/llupdatedownloader.cpp | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatedownloader.cpp b/indra/viewer_components/updater/llupdatedownloader.cpp index 53c729469b..d44a6c8d7c 100755 --- a/indra/viewer_components/updater/llupdatedownloader.cpp +++ b/indra/viewer_components/updater/llupdatedownloader.cpp @@ -56,7 +56,7 @@ public: bool isDownloading(void); size_t onHeader(void * header, size_t size); size_t onBody(void * header, size_t size); - int onProgress(double downloadSize, double bytesDownloaded); + int onProgress(curl_off_t downloadSize, curl_off_t bytesDownloaded); void resume(void); void setBandwidthLimit(U64 bytesPerSecond); @@ -174,11 +174,11 @@ namespace { } - int progress_callback(void * downloader, - double dowloadTotal, - double downloadNow, - double uploadTotal, - double uploadNow) + int xferinfo_callback(void * downloader, + curl_off_t dowloadTotal, + curl_off_t downloadNow, + curl_off_t uploadTotal, + curl_off_t uploadNow) { return reinterpret_cast(downloader)-> onProgress(dowloadTotal, downloadNow); @@ -386,9 +386,9 @@ size_t LLUpdateDownloader::Implementation::onBody(void * buffer, size_t size) } -int LLUpdateDownloader::Implementation::onProgress(double downloadSize, double bytesDownloaded) +int LLUpdateDownloader::Implementation::onProgress(curl_off_t downloadSize, curl_off_t bytesDownloaded) { - int downloadPercent = static_cast(100. * (bytesDownloaded / downloadSize)); + int downloadPercent = static_cast(100.0 * ((double) bytesDownloaded / (double) downloadSize)); if(downloadPercent > mDownloadPercent) { mDownloadPercent = downloadPercent; @@ -396,8 +396,8 @@ int LLUpdateDownloader::Implementation::onProgress(double downloadSize, double b event["pump"] = LLUpdaterService::pumpName(); LLSD payload; payload["type"] = LLSD(LLUpdaterService::PROGRESS); - payload["download_size"] = downloadSize; - payload["bytes_downloaded"] = bytesDownloaded; + payload["download_size"] = (LLSD::Integer) downloadSize; + payload["bytes_downloaded"] = (LLSD::Integer) bytesDownloaded; event["payload"] = payload; LLEventPumps::instance().obtain("mainlooprepeater").post(event); @@ -480,9 +480,9 @@ void LLUpdateDownloader::Implementation::initializeCurlGet(std::string const & u } throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_HTTPGET, true)); throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_URL, url.c_str())); - throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_PROGRESSFUNCTION, &progress_callback)); - throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_PROGRESSDATA, this)); - throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_NOPROGRESS, false)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_XFERINFOFUNCTION, &xferinfo_callback)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_XFERINFODATA, this)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_NOPROGRESS, 0)); // if it's a required update set the bandwidth limit to 0 (unlimited) curl_off_t limit = mDownloadData["required"].asBoolean() ? 0 : mBandwidthLimit; throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_MAX_RECV_SPEED_LARGE, limit)); -- cgit v1.2.3 From d253f485380a108e2ad1e9409c7ec3e00eb5760d Mon Sep 17 00:00:00 2001 From: Drake Arconis Date: Thu, 25 Feb 2016 15:02:32 -0500 Subject: Add SSL support to update downloader to enable possibility of secure downloads --- indra/viewer_components/updater/llupdatedownloader.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatedownloader.cpp b/indra/viewer_components/updater/llupdatedownloader.cpp index d44a6c8d7c..382689afa0 100755 --- a/indra/viewer_components/updater/llupdatedownloader.cpp +++ b/indra/viewer_components/updater/llupdatedownloader.cpp @@ -486,6 +486,9 @@ void LLUpdateDownloader::Implementation::initializeCurlGet(std::string const & u // if it's a required update set the bandwidth limit to 0 (unlimited) curl_off_t limit = mDownloadData["required"].asBoolean() ? 0 : mBandwidthLimit; throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_MAX_RECV_SPEED_LARGE, limit)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_CAINFO, gDirUtilp->getCAFile().c_str())); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_SSL_VERIFYHOST, 2)); + throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_SSL_VERIFYPEER, 1)); mDownloadPercent = 0; } -- cgit v1.2.3