From 17641c8427d05c4cde1fadd2ca059264d89bc818 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Apr 2015 14:23:31 -0700 Subject: Added a class to automate pumping the HttpRequest on the mainloop. Converted AccountingCostManager to use the new LLCore::Http library and coroutines. --- indra/newview/llaccountingcostmanager.cpp | 284 +++++++++++++++++------------- 1 file changed, 163 insertions(+), 121 deletions(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index a42286a9e4..c52e6e1172 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -27,90 +27,171 @@ #include "llviewerprecompiledheaders.h" #include "llaccountingcostmanager.h" #include "llagent.h" -#include "llcurl.h" -#include "llhttpclient.h" +#include "httpcommon.h" +#include "llcoros.h" +#include "lleventcoro.h" +#include "llcorehttputil.h" + //=============================================================================== -LLAccountingCostManager::LLAccountingCostManager() +LLAccountingCostManager::LLAccountingCostManager(): + mHttpRequest(), + mHttpHeaders(), + mHttpOptions(), + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), + mHttpPriority(0) { + mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + //mHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID; + } -//=============================================================================== -class LLAccountingCostResponder : public LLCurl::Responder + +// Coroutine for sending and processing avatar name cache requests. +// Do not call directly. See documentation in lleventcoro.h and llcoro.h for +// further explanation. +void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, + eSelectionType selectionType, const LLHandle observerHandle) { - LOG_CLASS(LLAccountingCostResponder); -public: - LLAccountingCostResponder( const LLSD& objectIDs, const LLHandle& observer_handle ) - : mObjectIDs( objectIDs ), - mObserverHandle( observer_handle ) - { - LLAccountingCostObserver* observer = mObserverHandle.get(); - if (observer) - { - mTransactionID = observer->getTransactionID(); - } - } + LLEventStream replyPump("AccountingCostReply", true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); - void clearPendingRequests ( void ) - { - for ( LLSD::array_iterator iter = mObjectIDs.beginArray(); iter != mObjectIDs.endArray(); ++iter ) - { - LLAccountingCostManager::getInstance()->removePendingObject( iter->asUUID() ); - } - } - -protected: - void httpFailure() - { - LL_WARNS() << dumpResponse() << LL_ENDL; - clearPendingRequests(); - - LLAccountingCostObserver* observer = mObserverHandle.get(); - if (observer && observer->getTransactionID() == mTransactionID) - { - observer->setErrorStatus(getStatus(), getReason()); - } - } - - void httpSuccess() - { - const LLSD& content = getContent(); - //Check for error - if ( !content.isMap() || content.has("error") ) - { - failureResult(HTTP_INTERNAL_ERROR, "Error on fetched data", content); - return; - } - else if (content.has("selected")) - { - F32 physicsCost = 0.0f; - F32 networkCost = 0.0f; - F32 simulationCost = 0.0f; - - physicsCost = content["selected"]["physics"].asReal(); - networkCost = content["selected"]["streaming"].asReal(); - simulationCost = content["selected"]["simulation"].asReal(); - - SelectionCost selectionCost( /*transactionID,*/ physicsCost, networkCost, simulationCost ); - - LLAccountingCostObserver* observer = mObserverHandle.get(); - if (observer && observer->getTransactionID() == mTransactionID) - { - observer->onWeightsUpdate(selectionCost); - } - } - - clearPendingRequests(); - } - -private: - //List of posted objects - LLSD mObjectIDs; + LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) + << " with url '" << url << LL_ENDL; + + try + { + LLSD objectList; + U32 objectIndex = 0; + + IDIt IDIter = mObjectList.begin(); + IDIt IDIterEnd = mObjectList.end(); + + for (; IDIter != IDIterEnd; ++IDIter) + { + // Check to see if a request for this object has already been made. + if (mPendingObjectQuota.find(*IDIter) == mPendingObjectQuota.end()) + { + mPendingObjectQuota.insert(*IDIter); + objectList[objectIndex++] = *IDIter; + } + } + + mObjectList.clear(); + + //Post results + if (objectList.size() == 0) + return; + + std::string keystr; + if (selectionType == Roots) + { + keystr = "selected_roots"; + } + else if (selectionType == Prims) + { + keystr = "selected_prims"; + } + else + { + LL_INFOS() << "Invalid selection type " << LL_ENDL; + mObjectList.clear(); + mPendingObjectQuota.clear(); + return; + } - // Current request ID - LLUUID mTransactionID; + LLSD dataToPost = LLSD::emptyMap(); + dataToPost[keystr.c_str()] = objectList; + + LLAccountingCostObserver* observer = observerHandle.get(); + LLUUID transactionId = observer->getTransactionID(); + observer = NULL; + + LLSD results; + { // Scoping block for pumper object + LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(mHttpRequest); + LLCore::HttpHandle hhandle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, + mHttpPolicy, mHttpPriority, url, dataToPost, mHttpOptions, mHttpHeaders, + httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + LLCore::HttpStatus status = mHttpRequest->getStatus(); + LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << + " message = " << status.getMessage() << LL_ENDL; + mPendingObjectQuota.clear(); + return; + } + + results = waitForEventOn(self, replyPump); + LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + } + LLSD httpResults; + httpResults = results["http_result"]; + + do + { + observer = observerHandle.get(); + if ((!observer) || (observer->getTransactionID() != transactionId)) + { + if (!observer) + break; + LL_WARNS() << "Request transaction Id(" << transactionId + << ") does not match observer's transaction Id(" + << observer->getTransactionID() << ")." << LL_ENDL; + break; + } + + if (!httpResults["success"].asBoolean()) + { + LL_WARNS() << "Error result from LLCoreHttpUtil::HttpCoroHandler. Code " + << httpResults["status"] << ": '" << httpResults["message"] << "'" << LL_ENDL; + if (observer) + { + observer->setErrorStatus(httpResults["status"].asInteger(), httpResults["message"].asStringRef()); + } + break; + } + + if (!results.isMap() || results.has("error")) + { + LL_WARNS() << "Error on fetched data" << LL_ENDL; + observer->setErrorStatus(499, "Error on fetched data"); + break; + } + + if (results.has("selected")) + { + F32 physicsCost = 0.0f; + F32 networkCost = 0.0f; + F32 simulationCost = 0.0f; + + physicsCost = results["selected"]["physics"].asReal(); + networkCost = results["selected"]["streaming"].asReal(); + simulationCost = results["selected"]["simulation"].asReal(); + + SelectionCost selectionCost( physicsCost, networkCost, simulationCost); + + observer->onWeightsUpdate(selectionCost); + } + + } while (false); + + } + catch (std::exception e) + { + LL_WARNS() << "Caught exception '" << e.what() << "'" << LL_ENDL; + } + catch (...) + { + LL_WARNS() << "Caught unknown exception." << LL_ENDL; + } + + mPendingObjectQuota.clear(); +} - // Cost update observer handle - LLHandle mObserverHandle; -}; //=============================================================================== void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const std::string& url, @@ -119,50 +200,11 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, // Invoking system must have already determined capability availability if ( !url.empty() ) { - LLSD objectList; - U32 objectIndex = 0; - - IDIt IDIter = mObjectList.begin(); - IDIt IDIterEnd = mObjectList.end(); - - for ( ; IDIter != IDIterEnd; ++IDIter ) - { - // Check to see if a request for this object has already been made. - if ( mPendingObjectQuota.find( *IDIter ) == mPendingObjectQuota.end() ) - { - mPendingObjectQuota.insert( *IDIter ); - objectList[objectIndex++] = *IDIter; - } - } - - mObjectList.clear(); - - //Post results - if ( objectList.size() > 0 ) - { - std::string keystr; - if ( selectionType == Roots ) - { - keystr="selected_roots"; - } - else - if ( selectionType == Prims ) - { - keystr="selected_prims"; - } - else - { - LL_INFOS()<<"Invalid selection type "< Date: Fri, 3 Apr 2015 14:50:15 -0700 Subject: Comment out debug LL_INFOs and added TODO comment. --- indra/newview/llaccountingcostmanager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index c52e6e1172..a80715dad5 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -110,7 +110,7 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin LLSD results; { // Scoping block for pumper object - LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; LLCoreHttpUtil::HttpRequestPumper pumper(mHttpRequest); LLCore::HttpHandle hhandle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, mHttpPriority, url, dataToPost, mHttpOptions, mHttpHeaders, @@ -126,7 +126,7 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin } results = waitForEventOn(self, replyPump); - LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; } LLSD httpResults; httpResults = results["http_result"]; @@ -135,7 +135,9 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin { observer = observerHandle.get(); if ((!observer) || (observer->getTransactionID() != transactionId)) - { + { // *TODO: Rider: I've noticed that getTransactionID() does not + // always match transactionId (the new transaction Id does not show a + // corresponding request.) if (!observer) break; LL_WARNS() << "Request transaction Id(" << transactionId -- cgit v1.2.3 From 8a76284e488227b9ff83917cdec2ea011c088527 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Apr 2015 10:30:10 -0700 Subject: Results from code review with Nat. Consolidate some of the coroutine/http code into a single adapter. --- indra/newview/llaccountingcostmanager.cpp | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index a80715dad5..f33f67e76d 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -53,10 +53,6 @@ LLAccountingCostManager::LLAccountingCostManager(): void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, eSelectionType selectionType, const LLHandle observerHandle) { - LLEventStream replyPump("AccountingCostReply", true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); - LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) << " with url '" << url << LL_ENDL; @@ -108,36 +104,22 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin LLUUID transactionId = observer->getTransactionID(); observer = NULL; - LLSD results; - { // Scoping block for pumper object - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(mHttpRequest); - LLCore::HttpHandle hhandle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, - mHttpPolicy, mHttpPriority, url, dataToPost, mHttpOptions, mHttpHeaders, - httpHandler.get()); + LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - if (hhandle == LLCORE_HTTP_HANDLE_INVALID) - { - LLCore::HttpStatus status = mHttpRequest->getStatus(); - LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << - " message = " << status.getMessage() << LL_ENDL; - mPendingObjectQuota.clear(); - return; - } + LLSD results = httpAdapter.postAndYield(self, mHttpRequest, url, dataToPost); - results = waitForEventOn(self, replyPump); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; - } LLSD httpResults; httpResults = results["http_result"]; + // do/while(false) allows error conditions to break out of following + // block while normal flow goes forward once. do { observer = observerHandle.get(); if ((!observer) || (observer->getTransactionID() != transactionId)) { // *TODO: Rider: I've noticed that getTransactionID() does not // always match transactionId (the new transaction Id does not show a - // corresponding request.) + // corresponding request.) (ask Vir) if (!observer) break; LL_WARNS() << "Request transaction Id(" << transactionId -- cgit v1.2.3 From fe34b3ef725b83af0deeffcf8bf6ef9769224e8d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Apr 2015 11:23:20 -0700 Subject: Remove unused mHttpPriority --- indra/newview/llaccountingcostmanager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index f33f67e76d..6337fbe444 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -37,8 +37,7 @@ LLAccountingCostManager::LLAccountingCostManager(): mHttpRequest(), mHttpHeaders(), mHttpOptions(), - mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpPriority(0) + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) { mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); -- cgit v1.2.3 From aba8d5e488d771f3d30ee75f0fbca30747adb7d1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 9 Jun 2015 13:06:09 -0700 Subject: Removed homelocation responder (rolled into llagent) Removed sdhandler from llagent. Removed unused values from llacountingccostmgr Fixed smart pontier creation in llfacebook --- indra/newview/llaccountingcostmanager.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index 6337fbe444..f928c84ecb 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -35,13 +35,9 @@ //=============================================================================== LLAccountingCostManager::LLAccountingCostManager(): mHttpRequest(), - mHttpHeaders(), - mHttpOptions(), mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) { mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); - mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); //mHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID; } -- 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/newview/llaccountingcostmanager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index f928c84ecb..cd9146ea16 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -45,10 +45,10 @@ LLAccountingCostManager::LLAccountingCostManager(): // Coroutine for sending and processing avatar name cache requests. // Do not call directly. See documentation in lleventcoro.h and llcoro.h for // further explanation. -void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, +void LLAccountingCostManager::accountingCostCoro(std::string url, eSelectionType selectionType, const LLHandle observerHandle) { - LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) + LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName() << " with url '" << url << LL_ENDL; try @@ -101,7 +101,7 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - LLSD results = httpAdapter.postAndYield(self, mHttpRequest, url, dataToPost); + LLSD results = httpAdapter.postAndYield(mHttpRequest, url, dataToPost); LLSD httpResults; httpResults = results["http_result"]; @@ -181,7 +181,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, { std::string coroname = LLCoros::instance().launch("LLAccountingCostManager::accountingCostCoro", - boost::bind(&LLAccountingCostManager::accountingCostCoro, this, _1, url, selectionType, observer_handle)); + boost::bind(&LLAccountingCostManager::accountingCostCoro, this, url, selectionType, observer_handle)); LL_DEBUGS() << coroname << " with url '" << url << LL_ENDL; } -- 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/newview/llaccountingcostmanager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index cd9146ea16..f928c84ecb 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -45,10 +45,10 @@ LLAccountingCostManager::LLAccountingCostManager(): // Coroutine for sending and processing avatar name cache requests. // Do not call directly. See documentation in lleventcoro.h and llcoro.h for // further explanation. -void LLAccountingCostManager::accountingCostCoro(std::string url, +void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, eSelectionType selectionType, const LLHandle observerHandle) { - LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName() + LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) << " with url '" << url << LL_ENDL; try @@ -101,7 +101,7 @@ void LLAccountingCostManager::accountingCostCoro(std::string url, LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - LLSD results = httpAdapter.postAndYield(mHttpRequest, url, dataToPost); + LLSD results = httpAdapter.postAndYield(self, mHttpRequest, url, dataToPost); LLSD httpResults; httpResults = results["http_result"]; @@ -181,7 +181,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, { std::string coroname = LLCoros::instance().launch("LLAccountingCostManager::accountingCostCoro", - boost::bind(&LLAccountingCostManager::accountingCostCoro, this, url, selectionType, observer_handle)); + boost::bind(&LLAccountingCostManager::accountingCostCoro, this, _1, url, selectionType, observer_handle)); LL_DEBUGS() << coroname << " with url '" << url << LL_ENDL; } -- 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/newview/llaccountingcostmanager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index f928c84ecb..cd9146ea16 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -45,10 +45,10 @@ LLAccountingCostManager::LLAccountingCostManager(): // Coroutine for sending and processing avatar name cache requests. // Do not call directly. See documentation in lleventcoro.h and llcoro.h for // further explanation. -void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::string url, +void LLAccountingCostManager::accountingCostCoro(std::string url, eSelectionType selectionType, const LLHandle observerHandle) { - LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName(self) + LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName() << " with url '" << url << LL_ENDL; try @@ -101,7 +101,7 @@ void LLAccountingCostManager::accountingCostCoro(LLCoros::self& self, std::strin LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - LLSD results = httpAdapter.postAndYield(self, mHttpRequest, url, dataToPost); + LLSD results = httpAdapter.postAndYield(mHttpRequest, url, dataToPost); LLSD httpResults; httpResults = results["http_result"]; @@ -181,7 +181,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, { std::string coroname = LLCoros::instance().launch("LLAccountingCostManager::accountingCostCoro", - boost::bind(&LLAccountingCostManager::accountingCostCoro, this, _1, url, selectionType, observer_handle)); + boost::bind(&LLAccountingCostManager::accountingCostCoro, this, url, selectionType, observer_handle)); LL_DEBUGS() << coroname << " with url '" << url << LL_ENDL; } -- 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/newview/llaccountingcostmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index cd9146ea16..d5027d13fa 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -101,7 +101,7 @@ void LLAccountingCostManager::accountingCostCoro(std::string url, LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - LLSD results = httpAdapter.postAndYield(mHttpRequest, url, dataToPost); + LLSD results = httpAdapter.postAndSuspend(mHttpRequest, url, dataToPost); LLSD httpResults; httpResults = results["http_result"]; -- cgit v1.2.3 From 83836d91178235e5c188020ac57c9a296343e83b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 28 Sep 2015 17:06:53 -0700 Subject: MAINT-5676: Cleaned up the way we were keeping track of outstanding object cost requests. MAINT-5626: Fixed a typo/transcription error/fat finger mistake where I was missing the report of the land impact of selected objects. --- indra/newview/llaccountingcostmanager.cpp | 87 +++++++++++++++---------------- 1 file changed, 41 insertions(+), 46 deletions(-) (limited to 'indra/newview/llaccountingcostmanager.cpp') diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index d5027d13fa..92a5413adb 100755 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -31,14 +31,12 @@ #include "llcoros.h" #include "lleventcoro.h" #include "llcorehttputil.h" +#include +#include //=============================================================================== -LLAccountingCostManager::LLAccountingCostManager(): - mHttpRequest(), - mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) +LLAccountingCostManager::LLAccountingCostManager() { - mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); - //mHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID; } @@ -51,30 +49,24 @@ void LLAccountingCostManager::accountingCostCoro(std::string url, LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName() << " with url '" << url << LL_ENDL; + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("AccountingCost", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + try { - LLSD objectList; - U32 objectIndex = 0; + uuid_set_t diffSet; - IDIt IDIter = mObjectList.begin(); - IDIt IDIterEnd = mObjectList.end(); + std::set_difference(mObjectList.begin(), mObjectList.end(), + mPendingObjectQuota.begin(), mPendingObjectQuota.end(), + std::inserter(diffSet, diffSet.begin())); - for (; IDIter != IDIterEnd; ++IDIter) - { - // Check to see if a request for this object has already been made. - if (mPendingObjectQuota.find(*IDIter) == mPendingObjectQuota.end()) - { - mPendingObjectQuota.insert(*IDIter); - objectList[objectIndex++] = *IDIter; - } - } + if (diffSet.empty()) + return; mObjectList.clear(); - //Post results - if (objectList.size() == 0) - return; - std::string keystr; if (selectionType == Roots) { @@ -87,11 +79,18 @@ void LLAccountingCostManager::accountingCostCoro(std::string url, else { LL_INFOS() << "Invalid selection type " << LL_ENDL; - mObjectList.clear(); - mPendingObjectQuota.clear(); return; } + LLSD objectList(LLSD::emptyMap()); + + for (uuid_set_t::iterator it = diffSet.begin(); it != diffSet.end(); ++it) + { + objectList.append(*it); + } + + mPendingObjectQuota.insert(diffSet.begin(), diffSet.end()); + LLSD dataToPost = LLSD::emptyMap(); dataToPost[keystr.c_str()] = objectList; @@ -99,27 +98,27 @@ void LLAccountingCostManager::accountingCostCoro(std::string url, LLUUID transactionId = observer->getTransactionID(); observer = NULL; - LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy); - LLSD results = httpAdapter.postAndSuspend(mHttpRequest, url, dataToPost); - LLSD httpResults; - httpResults = results["http_result"]; + LLSD results = httpAdapter->postAndSuspend(httpRequest, url, dataToPost); + + LLSD httpResults = results["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); // do/while(false) allows error conditions to break out of following // block while normal flow goes forward once. do { observer = observerHandle.get(); - if ((!observer) || (observer->getTransactionID() != transactionId)) - { // *TODO: Rider: I've noticed that getTransactionID() does not - // always match transactionId (the new transaction Id does not show a - // corresponding request.) (ask Vir) - if (!observer) - break; - LL_WARNS() << "Request transaction Id(" << transactionId - << ") does not match observer's transaction Id(" - << observer->getTransactionID() << ")." << LL_ENDL; + + if (!status || results.has("error")) + { + LL_WARNS() << "Error on fetched data" << LL_ENDL; + if (!status) + observer->setErrorStatus(status.getType(), status.toString()); + else + observer->setErrorStatus(499, "Error on fetched data"); + break; } @@ -134,22 +133,18 @@ void LLAccountingCostManager::accountingCostCoro(std::string url, break; } - if (!results.isMap() || results.has("error")) - { - LL_WARNS() << "Error on fetched data" << LL_ENDL; - observer->setErrorStatus(499, "Error on fetched data"); - break; - } if (results.has("selected")) { + LLSD selected = results["selected"]; + F32 physicsCost = 0.0f; F32 networkCost = 0.0f; F32 simulationCost = 0.0f; - physicsCost = results["selected"]["physics"].asReal(); - networkCost = results["selected"]["streaming"].asReal(); - simulationCost = results["selected"]["simulation"].asReal(); + physicsCost = selected["physics"].asReal(); + networkCost = selected["streaming"].asReal(); + simulationCost = selected["simulation"].asReal(); SelectionCost selectionCost( physicsCost, networkCost, simulationCost); -- cgit v1.2.3