diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llmessage/llcorehttputil.cpp | 7 | ||||
| -rwxr-xr-x | indra/newview/llagent.h | 3 | ||||
| -rwxr-xr-x | indra/newview/llappearancemgr.cpp | 208 | ||||
| -rwxr-xr-x | indra/newview/llappearancemgr.h | 8 | 
4 files changed, 124 insertions, 102 deletions
| diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index d964ff7100..db1cfbe638 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -263,8 +263,6 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons      buildStatusEntry(response, status, result); -#if 1 -    // commenting out, but keeping since this can be useful for debugging      if (!status)      {          LLSD &httpStatus = result[HttpCoroutineAdapter::HTTP_RESULTS]; @@ -276,10 +274,11 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons          bas >> std::noskipws;          bodyData.assign(std::istream_iterator<U8>(bas), std::istream_iterator<U8>());          httpStatus["error_body"] = LLSD(bodyData); - +#if 1 +        // commenting out, but keeping since this can be useful for debugging          LL_WARNS() << "Returned body=" << std::endl << httpStatus["error_body"].asString() << LL_ENDL; -    }  #endif +    }      mReplyPump.post(result);  } diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 5731f4db89..d46973ddee 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -36,6 +36,7 @@  #include "llpermissionsflags.h"  #include "llevents.h"  #include "v3dmath.h" +#include "httprequest.h"  #include "llcorehttputil.h"  #include <boost/function.hpp> @@ -935,6 +936,8 @@ public:      bool requestPostCapability(const std::string &capName, LLSD &postData, httpCallback_t cbSuccess = NULL, httpCallback_t cbFailure = NULL);      bool requestGetCapability(const std::string &capName, httpCallback_t cbSuccess = NULL, httpCallback_t cbFailure = NULL); +    LLCore::HttpRequest::policy_t getAgentPolicy() const { return mHttpPolicy; } +  /**                    Utility   **                                                                            **   *******************************************************************************/ diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index eea585e998..720a4ff2df 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"].asString() : 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()) diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 9b6ceb7d3e..118648b7c3 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -225,15 +225,9 @@ public:  	std::string getAppearanceServiceURL() const; -	bool testCOFRequestVersion() const; -	void decrementInFlightCounter() -	{ -		mInFlightCounter = llmax(mInFlightCounter - 1, 0); -	} -  private: -    void serverAppearanceUpdateSuccess(const LLSD &result); +    void serverAppearanceUpdateCoro();      static void debugAppearanceUpdateCOF(const LLSD& content);  	std::string		mAppearanceServiceURL; | 
