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. --- .../viewer_components/updater/llupdatechecker.cpp | 88 +++++++++++----------- 1 file changed, 42 insertions(+), 46 deletions(-) (limited to 'indra/viewer_components/updater/llupdatechecker.cpp') 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, -- 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/viewer_components/updater/llupdatechecker.cpp') 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 -- 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 - 1 file changed, 1 deletion(-) (limited to 'indra/viewer_components/updater/llupdatechecker.cpp') 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" -- 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 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/viewer_components/updater/llupdatechecker.cpp') 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); -- 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 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/viewer_components/updater/llupdatechecker.cpp') 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); -- 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 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/viewer_components/updater/llupdatechecker.cpp') 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); -- 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/llupdatechecker.cpp') 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