diff options
author | Rider Linden <rider@lindenlab.com> | 2015-10-06 14:17:37 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2015-10-06 14:17:37 -0700 |
commit | edd23c42fa3dc1ac7baa06fb2e02e1a602030a75 (patch) | |
tree | 60573e376897d024cc38d3844cba8301ce4b330e /indra/newview/llappearancemgr.cpp | |
parent | 4334fd27e2215c1bfad3aa7ab7130b8c6b289de5 (diff) |
MAINT-5693: Consolidated the avatar appearance request into a coroutine. If the request fails because of a stale COF, then rerequest with the corrected one.
Diffstat (limited to 'indra/newview/llappearancemgr.cpp')
-rwxr-xr-x | indra/newview/llappearancemgr.cpp | 208 |
1 files changed, 117 insertions, 91 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index eea585e998..4b7115d6b3 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -57,6 +57,8 @@ #include "llhttpsdhandler.h" #include "llcorehttputil.h" #include "llappviewer.h" +#include "llcoros.h" +#include "lleventcoro.h" #if LL_MSVC // disable boost::lexical_cast warning @@ -3348,84 +3350,138 @@ LLSD LLAppearanceMgr::dumpCOF() const void LLAppearanceMgr::requestServerAppearanceUpdate() { + LLCoros::instance().launch("LLAppearanceMgr::serverAppearanceUpdateCoro", + boost::bind(&LLAppearanceMgr::serverAppearanceUpdateCoro, this)); +} - if (!testCOFRequestVersion()) - { - // *TODO: LL_LOG message here - return; - } +void LLAppearanceMgr::serverAppearanceUpdateCoro() +{ + // If we have already received an update for this or higher cof version, ignore. + S32 cofVersion = getCOFVersion(); + S32 lastRcv = gAgentAvatarp->mLastUpdateReceivedCOFVersion; + S32 lastReq = gAgentAvatarp->mLastUpdateRequestCOFVersion; - if ((mInFlightCounter > 0) && (mInFlightTimer.hasExpired())) - { - LL_WARNS("Avatar") << "in flight timer expired, resetting " << LL_ENDL; - mInFlightCounter = 0; - } + //---------------- + // move out of coroutine + if (!gAgent.getRegion()) + { + LL_WARNS("Avatar") << "Region not set, cannot request server appearance update" << LL_ENDL; + return; + } + if (gAgent.getRegion()->getCentralBakeVersion() == 0) + { + LL_WARNS("Avatar") << "Region does not support baking" << LL_ENDL; + } - if (gAgentAvatarp->isEditingAppearance()) - { - LL_WARNS("Avatar") << "Avatar editing appearance, not sending request." << LL_ENDL; - // don't send out appearance updates if in appearance editing mode - return; - } + std::string url = gAgent.getRegion()->getCapability("UpdateAvatarAppearance"); + if (url.empty()) + { + LL_WARNS("Agent") << "Could not retrieve region capability \"UpdateAvatarAppearance\"" << LL_ENDL; + } - if (!gAgent.getRegion()) - { - LL_WARNS("Avatar") << "Region not set, cannot request server appearance update" << LL_ENDL; - return; - } - if (gAgent.getRegion()->getCentralBakeVersion() == 0) - { - LL_WARNS("Avatar") << "Region does not support baking" << LL_ENDL; - } + //---------------- + if (gAgentAvatarp->isEditingAppearance()) + { + LL_WARNS("Avatar") << "Avatar editing appearance, not sending request." << LL_ENDL; + // don't send out appearance updates if in appearance editing mode + return; + } - LLSD postData; - S32 cof_version = LLAppearanceMgr::instance().getCOFVersion(); - if (gSavedSettings.getBOOL("DebugAvatarExperimentalServerAppearanceUpdate")) - { - postData = LLAppearanceMgr::instance().dumpCOF(); - } - else - { - postData["cof_version"] = cof_version; - if (gSavedSettings.getBOOL("DebugForceAppearanceRequestFailure")) - { - postData["cof_version"] = cof_version + 999; - } - } + LL_DEBUGS("Avatar") << "COF version=" << cofVersion << + " last_rcv=" << lastRcv << + " last_req=" << lastReq << LL_ENDL; - mInFlightCounter++; - mInFlightTimer.setTimerExpirySec(60.0); + if (cofVersion < lastRcv) + { + LL_WARNS("Avatar") << "Have already received update for cof version " << lastRcv + << " will not request for " << cofVersion << LL_ENDL; + return; + } + if (lastReq >= cofVersion) + { + LL_WARNS("Avatar") << "Request already in flight for cof version " << lastReq + << " will not request for " << cofVersion << LL_ENDL; + return; + } + + // Actually send the request. + LL_DEBUGS("Avatar") << "Will send request for cof_version " << cofVersion << LL_ENDL; - llassert(cof_version >= gAgentAvatarp->mLastUpdateRequestCOFVersion); - gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter( + "UpdateAvatarAppearance", gAgent.getAgentPolicy())); - if (!gAgent.requestPostCapability("UpdateAvatarAppearance", postData, - static_cast<LLAgent::httpCallback_t>(boost::bind(&LLAppearanceMgr::serverAppearanceUpdateSuccess, this, _1)), - static_cast<LLAgent::httpCallback_t>(boost::bind(&LLAppearanceMgr::decrementInFlightCounter, this)))) + S32 reqCofVersion = cofVersion; + if (gSavedSettings.getBOOL("DebugForceAppearanceRequestFailure")) { - LL_WARNS("Avatar") << "Unable to access UpdateAvatarAppearance in this region." << LL_ENDL; + reqCofVersion += 999; + LL_WARNS("Avatar") << "Forcing version failure on COF Baking" << LL_ENDL; } -} -void LLAppearanceMgr::serverAppearanceUpdateSuccess(const LLSD &result) -{ - decrementInFlightCounter(); - if (result["success"].asBoolean()) + do { - LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); + + LLSD postData; + if (gSavedSettings.getBOOL("DebugAvatarExperimentalServerAppearanceUpdate")) { - dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", result); + postData = dumpCOF(); } - } - else - { - LL_WARNS("Avatar") << "Non success response for change appearance" << LL_ENDL; + else + { + postData["cof_version"] = reqCofVersion; + } + + gAgentAvatarp->mLastUpdateRequestCOFVersion = reqCofVersion; + + LLSD result = httpAdapter->postAndSuspend(httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status || !result["success"].asBoolean()) + { + if (httpResults.has("error_body")) + { + std::istringstream bodystream(httpResults["error_body"].asStringRef()); + LLSD body_llsd; + + if (LLSDSerialize::fromXML(body_llsd, bodystream, true) == LLSDParser::PARSE_FAILURE) + { + LL_WARNS() << "Unable to parse body as LLSD" << LL_ENDL; + } + else + { + result = body_llsd; + } + } + + std::string message = (result.has("error")) ? result["error"] : status.toString(); + LL_WARNS("Avatar") << "Appearance Failure. server responded with \"" << message << "\"" << LL_ENDL; + + // We may have requested a bake for a stale COF (especially if the inventory + // is still updating. If that is the case re send the request with the + // corrected COF version. (This may also be the case if the viewer is running + // on multiple machines. + if (result.has("expected")) + { + reqCofVersion = result["expected"].asInteger(); + + LL_WARNS("Avatar") << "Will Retry with expected COF value of " << reqCofVersion << LL_ENDL; + continue; + } + + break; + } + + LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) { - debugAppearanceUpdateCOF(result); + dump_sequential_xml(gAgentAvatarp->getFullname() + "_appearance_request_ok", result); } - } + + break; + } while (true); + } /*static*/ @@ -3513,36 +3569,6 @@ void LLAppearanceMgr::debugAppearanceUpdateCOF(const LLSD& content) } -bool LLAppearanceMgr::testCOFRequestVersion() const -{ - // If we have already received an update for this or higher cof version, ignore. - S32 cof_version = getCOFVersion(); - S32 last_rcv = gAgentAvatarp->mLastUpdateReceivedCOFVersion; - S32 last_req = gAgentAvatarp->mLastUpdateRequestCOFVersion; - - LL_DEBUGS("Avatar") << "cof_version " << cof_version - << " last_rcv " << last_rcv - << " last_req " << last_req - << " in flight " << mInFlightCounter - << LL_ENDL; - if (cof_version < last_rcv) - { - LL_DEBUGS("Avatar") << "Have already received update for cof version " << last_rcv - << " will not request for " << cof_version << LL_ENDL; - return false; - } - if (/*mInFlightCounter > 0 &&*/ last_req >= cof_version) - { - LL_DEBUGS("Avatar") << "Request already in flight for cof version " << last_req - << " will not request for " << cof_version << LL_ENDL; - return false; - } - - // Actually send the request. - LL_DEBUGS("Avatar") << "Will send request for cof_version " << cof_version << LL_ENDL; - return true; -} - std::string LLAppearanceMgr::getAppearanceServiceURL() const { if (gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride").empty()) |