summaryrefslogtreecommitdiff
path: root/indra/newview/llappearancemgr.cpp
diff options
context:
space:
mode:
authorLogan Dethrow <log@lindenlab.com>2012-11-19 16:30:14 -0500
committerLogan Dethrow <log@lindenlab.com>2012-11-19 16:30:14 -0500
commit81219ad03b59a5fcd80ee450b7606c6bb64f4c7d (patch)
treeb7e4db0ebd7700c25952f18605477b5e0812a0a3 /indra/newview/llappearancemgr.cpp
parent25caf1f4d37903479d9e5e5e239553664594c2f0 (diff)
Moved implementation of incrementCofVersion to llappearancemgr.cpp. Changed retry logic to use the more robust mRetryPolicy instead of my own previous implementation.
Diffstat (limited to 'indra/newview/llappearancemgr.cpp')
-rwxr-xr-xindra/newview/llappearancemgr.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 4e103bb75e..e3ac052961 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -2776,6 +2776,81 @@ void LLAppearanceMgr::requestServerAppearanceUpdate(LLCurl::ResponderPtr respond
mLastUpdateRequestCOFVersion = cof_version;
}
+class LLIncrementCofVersionResponder : public LLHTTPClient::Responder
+{
+public:
+ LLIncrementCofVersionResponder() : LLHTTPClient::Responder()
+ {
+ mRetryPolicy = new LLAdaptiveRetryPolicy(1.0, 16.0, 2.0, 5);
+ }
+
+ virtual ~LLIncrementCofVersionResponder()
+ {
+ }
+
+ virtual void result(const LLSD &pContent)
+ {
+ llinfos << "Successfully incremented agent's COF." << llendl;
+ S32 new_version = pContent["category"]["version"].asInteger();
+
+ LLAppearanceMgr* app_mgr = LLAppearanceMgr::getInstance();
+
+ // cof_version should have increased
+ llassert(new_version > app_mgr->mLastUpdateRequestCOFVersion);
+
+ app_mgr->mLastUpdateRequestCOFVersion = new_version;
+ }
+ virtual void error(U32 pStatus, const std::string& pReason)
+ {
+ llwarns << "While attempting to increment the agent's cof we got an error because '"
+ << pReason << "' [status:" << pStatus << "]" << llendl;
+ F32 seconds_to_wait;
+ if (mRetryPolicy->shouldRetry(pStatus,seconds_to_wait))
+ {
+ llinfos << "retrying" << llendl;
+ doAfterInterval(boost::bind(&LLAppearanceMgr::incrementCofVersion,
+ LLAppearanceMgr::getInstance(),
+ LLHTTPClient::ResponderPtr(this)),
+ seconds_to_wait);
+ }
+ else
+ {
+ llwarns << "giving up after too many retries" << llendl;
+ }
+ }
+
+ LLPointer<LLHTTPRetryPolicy> mRetryPolicy;
+};
+
+void LLAppearanceMgr::incrementCofVersion(LLHTTPClient::ResponderPtr responder_ptr)
+{
+ // If we don't have a region, report it as an error
+ if (gAgent.getRegion() == NULL)
+ {
+ llwarns << "Region not set, cannot request cof_version increment" << llendl;
+ return;
+ }
+
+ std::string url = gAgent.getRegion()->getCapability("IncrementCofVersion");
+ if (url.empty())
+ {
+ llwarns << "No cap for IncrementCofVersion." << llendl;
+ return;
+ }
+
+ llinfos << "Requesting cof_version be incremented via capability to: "
+ << url << llendl;
+ LLSD headers;
+ LLSD body = LLSD::emptyMap();
+
+ if (!responder_ptr.get())
+ {
+ responder_ptr = LLHTTPClient::ResponderPtr(new LLIncrementCofVersionResponder());
+ }
+
+ LLHTTPClient::get(url, body, responder_ptr, headers, 30.0f);
+}
+
class LLShowCreatedOutfit: public LLInventoryCallback
{
public: