From 0ca3c5c7fdd6790d98259fc6d8459633896ce7a0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 12 Apr 2016 12:08:59 -0700 Subject: Added exponential timeout to retry, protect against attempting to downgrade the COF version in the bake request. --- indra/newview/llappearancemgr.cpp | 131 +++++++++++++++++++++++--------------- indra/newview/llappearancemgr.h | 2 + 2 files changed, 83 insertions(+), 50 deletions(-) (limited to 'indra') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 99dcb80a4a..df56d7403c 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -65,7 +65,12 @@ #pragma warning (disable:4702) #endif -#if 1 +namespace +{ + const S32 BAKE_RETRY_MAX_COUNT = 5; + const F32 BAKE_RETRY_TIMEOUT = 2.0F; +} + // *TODO$: LLInventoryCallback should be deprecated to conform to the new boost::bind/coroutine model. // temp code in transition void doAppearanceCb(LLPointer cb, LLUUID id) @@ -73,8 +78,6 @@ void doAppearanceCb(LLPointer cb, LLUUID id) if (cb.notNull()) cb->fire(id); } -#endif - std::string self_av_string() { @@ -3354,12 +3357,21 @@ LLSD LLAppearanceMgr::dumpCOF() const void LLAppearanceMgr::requestServerAppearanceUpdate() { - LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLAppearanceMgr::serverAppearanceUpdateCoro, this, _1); - LLCoprocedureManager::instance().enqueueCoprocedure("AIS", "LLAppearanceMgr::serverAppearanceUpdateCoro", proc); + if (!mOutstandingAppearanceBakeRequest) + { + mRerequestAppearanceBake = false; + LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLAppearanceMgr::serverAppearanceUpdateCoro, this, _1); + LLCoprocedureManager::instance().enqueueCoprocedure("AIS", "LLAppearanceMgr::serverAppearanceUpdateCoro", proc); + } + else + { + mRerequestAppearanceBake = true; + } } void LLAppearanceMgr::serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter) { + mRerequestAppearanceBake = false; if (!gAgent.getRegion()) { LL_WARNS("Avatar") << "Region not set, cannot request server appearance update" << LL_ENDL; @@ -3386,57 +3398,57 @@ void LLAppearanceMgr::serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAd return; } -#if 0 - static int reqcount = 0; - int r_count = ++reqcount; - LL_WARNS("Avatar") << "START: Server Bake request #" << r_count << "!" << LL_ENDL; -#endif - - // If we have already received an update for this or higher cof version, - // put a warning in the log but request anyway. - S32 cofVersion = getCOFVersion(); - S32 lastRcv = gAgentAvatarp->mLastUpdateReceivedCOFVersion; - S32 lastReq = gAgentAvatarp->mLastUpdateRequestCOFVersion; - - LL_INFOS("Avatar") << "Requesting COF version " << cofVersion << - " (Last Received:" << lastRcv << ")" << - " (Last Requested:" << lastReq << ")" << LL_ENDL; - - if ((cofVersion != LLViewerInventoryCategory::VERSION_UNKNOWN)) + llcoro::suspend(); + S32 retryCount(0); + bool bRetry; + do { - if (cofVersion < lastRcv) + BoolSetter outstanding(mOutstandingAppearanceBakeRequest); + + // If we have already received an update for this or higher cof version, + // put a warning in the log and cancel the request. + S32 cofVersion = getCOFVersion(); + S32 lastRcv = gAgentAvatarp->mLastUpdateReceivedCOFVersion; + S32 lastReq = gAgentAvatarp->mLastUpdateRequestCOFVersion; + + LL_INFOS("Avatar") << "Requesting COF version " << cofVersion << + " (Last Received:" << lastRcv << ")" << + " (Last Requested:" << lastReq << ")" << LL_ENDL; + + if (cofVersion == LLViewerInventoryCategory::VERSION_UNKNOWN) { - LL_WARNS("Avatar") << "Have already received update for cof version " << lastRcv - << " but requesting for " << cofVersion << LL_ENDL; + LL_WARNS("AVatar") << "COF version is unknown... not requesting until COF version is known." << LL_ENDL; + return; } - if (lastReq > cofVersion) + else { - LL_WARNS("Avatar") << "Request already in flight for cof version " << lastReq - << " but requesting for " << cofVersion << LL_ENDL; + if (cofVersion < lastRcv) + { + LL_WARNS("Avatar") << "Have already received update for cof version " << lastRcv + << " but requesting for " << cofVersion << LL_ENDL; + return; + } + if (lastReq > cofVersion) + { + LL_WARNS("Avatar") << "Request already in flight for cof version " << lastReq + << " but requesting for " << cofVersion << LL_ENDL; + return; + } } - } - - // Actually send the request. - LL_DEBUGS("Avatar") << "Will send request for cof_version " << cofVersion << LL_ENDL; -// LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter( -// "UpdateAvatarAppearance", gAgent.getAgentPolicy())); + // Actually send the request. + LL_DEBUGS("Avatar") << "Will send request for cof_version " << cofVersion << LL_ENDL; - bool bRetry; - do - { bRetry = false; LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); - S32 reqCofVersion = getCOFVersion(); // Treat COF version (gets set by AISAPI as authoritative, - // not what the bake request tells us to use). if (gSavedSettings.getBOOL("DebugForceAppearanceRequestFailure")) { - reqCofVersion += 999; + cofVersion += 999; LL_WARNS("Avatar") << "Forcing version failure on COF Baking" << LL_ENDL; } - LL_INFOS() << "Requesting bake for COF version " << reqCofVersion << LL_ENDL; + LL_INFOS() << "Requesting bake for COF version " << cofVersion << LL_ENDL; LLSD postData; if (gSavedSettings.getBOOL("DebugAvatarExperimentalServerAppearanceUpdate")) @@ -3445,10 +3457,10 @@ void LLAppearanceMgr::serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAd } else { - postData["cof_version"] = reqCofVersion; + postData["cof_version"] = cofVersion; } - gAgentAvatarp->mLastUpdateRequestCOFVersion = reqCofVersion; + gAgentAvatarp->mLastUpdateRequestCOFVersion = cofVersion; LLSD result = httpAdapter->postAndSuspend(httpRequest, url, postData); @@ -3466,14 +3478,30 @@ void LLAppearanceMgr::serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAd // on multiple machines. if (result.has("expected")) { + S32 expectedCofVersion = result["expected"].asInteger(); + LL_WARNS("Avatar") << "Server expected " << expectedCofVersion << " as COF version" << LL_ENDL; + bRetry = true; // Wait for a 1/2 second before trying again. Just to keep from asking too quickly. - llcoro::suspendUntilTimeout(0.5); + if (++retryCount > BAKE_RETRY_MAX_COUNT) + { + LL_WARNS("Avatar") << "Bake retry count exceeded!" << LL_ENDL; + break; + } + F32 timeout = pow(BAKE_RETRY_TIMEOUT, static_cast(retryCount)) - 1.0; - LL_WARNS("Avatar") << "Server expected " << expectedCofVersion << " as COF version" << LL_ENDL; + LL_WARNS("Avatar") << "Bake retry #" << retryCount << " in " << timeout << " seconds." << LL_ENDL; + + llcoro::suspendUntilTimeout(timeout); + bRetry = true; continue; } + else + { + LL_WARNS("Avatar") << "No retry attempted." << LL_ENDL; + break; + } } LL_DEBUGS("Avatar") << "succeeded" << LL_ENDL; @@ -3484,10 +3512,11 @@ void LLAppearanceMgr::serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAd } while (bRetry); -#if 0 - LL_WARNS("Avatar") << "END: Server Bake request #" << r_count << "!" << LL_ENDL; -#endif - + if (mRerequestAppearanceBake) + { // A bake request came in while this one was still outstanding. + // Requeue ourself for a later request. + requestServerAppearanceUpdate(); + } } /*static*/ @@ -3855,7 +3884,9 @@ LLAppearanceMgr::LLAppearanceMgr(): mOutfitLocked(false), mInFlightCounter(0), mInFlightTimer(), - mIsInUpdateAppearanceFromCOF(false) + mIsInUpdateAppearanceFromCOF(false), + mOutstandingAppearanceBakeRequest(false), + mRerequestAppearanceBake(false) { LLOutfitObserver& outfit_observer = LLOutfitObserver::instance(); // unlock outfit on save operation completed diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index b97f9018c0..74024abf67 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -255,6 +255,8 @@ private: bool mAttachmentInvLinkEnabled; bool mOutfitIsDirty; bool mIsInUpdateAppearanceFromCOF; // to detect recursive calls. + bool mOutstandingAppearanceBakeRequest; // A bake request is outstanding. Do not overlap. + bool mRerequestAppearanceBake; /** * Lock for blocking operations on outfit until server reply or timeout exceed -- cgit v1.2.3 From 94d1a54e33845e1488ed52961416526ed232ddb1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 12 Apr 2016 13:56:49 -0700 Subject: Shift of negative is undefined. --- indra/llkdu/llimagej2ckdu.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 6a8959517d..282c859e9e 100755 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -1034,7 +1034,7 @@ all necessary level shifting, type conversion, rounding and truncation. */ val = (kdu_int32)(sp->fval*scale16); val = (val+128)>>8; // May be faster than true rounding val += 128; - if (val & ((-1)<<8)) + if (val & ((0xffffffffU)<<8)) { val = (val < 0 ? 0 : 255); } @@ -1052,7 +1052,7 @@ all necessary level shifting, type conversion, rounding and truncation. */ val = sp->ival; val = (val+offset)>>downshift; val += 128; - if (val & ((-1)<<8)) + if (val & ((0xffffffffU)<<8)) { val = (val < 0 ? 0 : 255); } @@ -1075,7 +1075,7 @@ all necessary level shifting, type conversion, rounding and truncation. */ val += (1<<(KDU_FIX_POINT-8))>>1; val >>= (KDU_FIX_POINT-8); val += 128; - if (val & ((-1)<<8)) + if (val & ((0xffffffffU)<<8)) { val = (val < 0 ? 0 : 255); } @@ -1094,7 +1094,7 @@ all necessary level shifting, type conversion, rounding and truncation. */ val = (val+offset)>>downshift; val <<= upshift; val += 128; - if (val & ((-1)<<8)) + if (val & ((0xffffffffU)<<8)) { val = (val < 0 ? 0 : 256 - (1<ival; val = (val+offset)>>downshift; val += 128; - if (val & ((-1)<<8)) + if (val & ((0xffffffffU)<<8)) { val = (val < 0 ? 0 : 255); } @@ -1132,7 +1132,7 @@ all necessary level shifting, type conversion, rounding and truncation. */ val = sp->ival; val <<= upshift; val += 128; - if (val & ((-1)<<8)) + if (val & ((0xffffffffU)<<8)) { val = (val < 0 ? 0 : 256 - (1< Date: Tue, 12 Apr 2016 16:51:16 -0700 Subject: MAINT-6305: Just bumping a warning level so I can track for debugging. --- indra/newview/llvoavatar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 21c38e9bc1..f11e69bae6 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -7396,7 +7396,7 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) if( isSelf() ) { - LL_DEBUGS("Avatar") << "this_update_cof_version " << this_update_cof_version + LL_WARNS("Avatar") << "this_update_cof_version " << this_update_cof_version << " last_update_request_cof_version " << last_update_request_cof_version << " my_cof_version " << LLAppearanceMgr::instance().getCOFVersion() << LL_ENDL; -- cgit v1.2.3 From 118e82e4775c88ace273d6012b5def8b9f19d08f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 13 Apr 2016 22:40:49 +0100 Subject: MAINT-6305: Serialize the AIS calls by reducing the queue size to 1, move the bake request out of the AIS queue. --- indra/llmessage/llcoproceduremanager.cpp | 3 ++- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llappearancemgr.cpp | 14 ++++++++++++++ indra/newview/llappearancemgr.h | 5 +++++ indra/newview/llvoavatar.cpp | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcoproceduremanager.cpp b/indra/llmessage/llcoproceduremanager.cpp index f0fe1ab01b..d4c0788b7d 100644 --- a/indra/llmessage/llcoproceduremanager.cpp +++ b/indra/llmessage/llcoproceduremanager.cpp @@ -36,7 +36,8 @@ static std::map DefaultPoolSizes = boost::assign::map_list_of (std::string("Upload"), 1) - (std::string("AIS"), 25); + (std::string("AIS"), 1); + // *TODO: Rider for the moment keep AIS calls serialized otherwise the COF will tend to get out of sync. #define DEFAULT_POOL_SIZE 5 diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index c4a8fe3532..07569aaaac 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -14446,7 +14446,7 @@ Type U32 Value - 25 + 1 PoolSizeUpload diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index df56d7403c..be538b3c4c 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -3359,9 +3359,14 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() { if (!mOutstandingAppearanceBakeRequest) { +#ifdef APPEARANCEBAKE_AS_IN_AIS_QUEUE mRerequestAppearanceBake = false; LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLAppearanceMgr::serverAppearanceUpdateCoro, this, _1); LLCoprocedureManager::instance().enqueueCoprocedure("AIS", "LLAppearanceMgr::serverAppearanceUpdateCoro", proc); +#else + LLCoros::instance().launch("", boost::bind(&LLAppearanceMgr::serverAppearanceUpdateCoro, this)); + +#endif } else { @@ -3369,8 +3374,17 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() } } +#ifdef APPEARANCEBAKE_AS_IN_AIS_QUEUE void LLAppearanceMgr::serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter) +#else +void LLAppearanceMgr::serverAppearanceUpdateCoro() +#endif { +#ifndef APPEARANCEBAKE_AS_IN_AIS_QUEUE + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter( + new LLCoreHttpUtil::HttpCoroutineAdapter("serverAppearanceUpdateCoro", LLCore::HttpRequest::DEFAULT_POLICY_ID)); +#endif + mRerequestAppearanceBake = false; if (!gAgent.getRegion()) { diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 74024abf67..bf181cb4ad 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -228,7 +228,12 @@ public: private: +#ifdef APPEARANCEBAKE_AS_IN_AIS_QUEUE void serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter); +#else + void serverAppearanceUpdateCoro(); +#endif + static void debugAppearanceUpdateCOF(const LLSD& content); std::string mAppearanceServiceURL; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index f11e69bae6..21c38e9bc1 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -7396,7 +7396,7 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) if( isSelf() ) { - LL_WARNS("Avatar") << "this_update_cof_version " << this_update_cof_version + LL_DEBUGS("Avatar") << "this_update_cof_version " << this_update_cof_version << " last_update_request_cof_version " << last_update_request_cof_version << " my_cof_version " << LLAppearanceMgr::instance().getCOFVersion() << LL_ENDL; -- cgit v1.2.3 From 9418e8b876a5193dea2ef2d583259909e595bbfe Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 13 Apr 2016 14:45:36 -0700 Subject: MAINT-6305: Forgot to add the coro name. --- indra/newview/llappearancemgr.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index be538b3c4c..772c4684ca 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -3364,7 +3364,8 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() LLCoprocedureManager::CoProcedure_t proc = boost::bind(&LLAppearanceMgr::serverAppearanceUpdateCoro, this, _1); LLCoprocedureManager::instance().enqueueCoprocedure("AIS", "LLAppearanceMgr::serverAppearanceUpdateCoro", proc); #else - LLCoros::instance().launch("", boost::bind(&LLAppearanceMgr::serverAppearanceUpdateCoro, this)); + LLCoros::instance().launch("serverAppearanceUpdateCoro", + boost::bind(&LLAppearanceMgr::serverAppearanceUpdateCoro, this)); #endif } -- cgit v1.2.3