summaryrefslogtreecommitdiff
path: root/indra/newview/llappearancemgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llappearancemgr.cpp')
-rw-r--r--indra/newview/llappearancemgr.cpp83
1 files changed, 60 insertions, 23 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index c04d6bad94..cb9e4471ef 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -2979,20 +2979,23 @@ class LLHTTPRetryPolicy: public LLThreadSafeRefCount
public:
LLHTTPRetryPolicy() {}
virtual ~LLHTTPRetryPolicy() {}
- virtual bool shouldRetry(U32 status, F32& seconds_to_wait) = 0;
+ virtual bool shouldRetry(S32 status, const LLSD& headers, F32& seconds_to_wait) = 0;
};
// Example of simplest possible policy, not necessarily recommended.
+// This would be a potentially dangerous policy to enable. Removing for now:
+#if 0
class LLAlwaysRetryImmediatelyPolicy: public LLHTTPRetryPolicy
{
public:
LLAlwaysRetryImmediatelyPolicy() {}
- bool shouldRetry(U32 status, F32& seconds_to_wait)
+ bool shouldRetry(S32 status, const LLSD& headers, F32& seconds_to_wait)
{
seconds_to_wait = 0.0;
return true;
}
};
+#endif
// Very general policy with geometric back-off after failures,
// up to a maximum delay, and maximum number of retries.
@@ -3009,10 +3012,25 @@ public:
{
}
- bool shouldRetry(U32 status, F32& seconds_to_wait)
+ bool shouldRetry(S32 status, const LLSD& headers, F32& seconds_to_wait)
{
- seconds_to_wait = mDelay;
- mDelay = llclamp(mDelay*mBackoffFactor,mMinDelay,mMaxDelay);
+#if 0
+ // *TODO: Test using status codes to only retry server errors.
+ // Only server errors would potentially return a different result on retry.
+ if (!isHttpServerErrorStatus(status)) return false;
+#endif
+
+#if 0
+ // *TODO: Honor server Retry-After header.
+ // Status 503 may ask us to wait for a certain amount of time before retrying.
+ if (!headers.has(HTTP_HEADER_RETRY_AFTER)
+ || !getSecondsUntilRetryAfter(headers[HTTP_HEADER_RETRY_AFTER].asStringRef(), seconds_to_wait))
+#endif
+ {
+ seconds_to_wait = mDelay;
+ mDelay = llclamp(mDelay*mBackoffFactor,mMinDelay,mMaxDelay);
+ }
+
mRetryCount++;
return (mRetryCount<=mMaxRetries);
}
@@ -3028,6 +3046,7 @@ private:
class RequestAgentUpdateAppearanceResponder: public LLHTTPClient::Responder
{
+ LOG_CLASS(RequestAgentUpdateAppearanceResponder);
public:
RequestAgentUpdateAppearanceResponder()
{
@@ -3038,13 +3057,19 @@ public:
{
}
+protected:
// Successful completion.
- /* virtual */ void result(const LLSD& content)
+ /* virtual */ void httpSuccess()
{
- LL_DEBUGS("Avatar") << "content: " << ll_pretty_print_sd(content) << LL_ENDL;
+ const LLSD& content = getContent();
+ if (!content.isMap())
+ {
+ failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content);
+ return;
+ }
if (content["success"].asBoolean())
{
- LL_DEBUGS("Avatar") << "OK" << LL_ENDL;
+ LL_DEBUGS("Avatar") << dumpResponse() << LL_ENDL;
if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage"))
{
dumpContents(gAgentAvatarp->getFullname() + "_appearance_request_ok", content);
@@ -3052,33 +3077,35 @@ public:
}
else
{
- onFailure(200);
+ failureResult(HTTP_INTERNAL_ERROR, "Non-success response", content);
}
}
// Error
- /*virtual*/ void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
+ /*virtual*/ void httpFailure()
{
- llwarns << "appearance update request failed, status: " << status << " reason: " << reason << " code: " << content["code"].asInteger() << " error: \"" << content["error"].asString() << "\"" << llendl;
+ const LLSD& content = getContent();
+ LL_WARNS("Avatar") << "appearance update request failed "
+ << dumpResponse() << LL_ENDL;
if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage"))
{
dumpContents(gAgentAvatarp->getFullname() + "_appearance_request_error", content);
debugCOF(content);
}
- onFailure(status);
- }
+ onFailure();
+ }
- void onFailure(U32 status)
+ void onFailure()
{
F32 seconds_to_wait;
- if (mRetryPolicy->shouldRetry(status,seconds_to_wait))
+ if (mRetryPolicy->shouldRetry(getStatus(), getResponseHeaders(), seconds_to_wait))
{
llinfos << "retrying" << llendl;
doAfterInterval(boost::bind(&LLAppearanceMgr::requestServerAppearanceUpdate,
LLAppearanceMgr::getInstance(),
- LLCurl::ResponderPtr(this)),
- seconds_to_wait);
+ LLHTTPClient::ResponderPtr(this)),
+ seconds_to_wait);
}
else
{
@@ -3281,6 +3308,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate(LLCurl::ResponderPtr respond
class LLIncrementCofVersionResponder : public LLHTTPClient::Responder
{
+ LOG_CLASS(LLIncrementCofVersionResponder);
public:
LLIncrementCofVersionResponder() : LLHTTPClient::Responder()
{
@@ -3291,10 +3319,17 @@ public:
{
}
- virtual void result(const LLSD &pContent)
+protected:
+ virtual void httpSuccess()
{
llinfos << "Successfully incremented agent's COF." << llendl;
- S32 new_version = pContent["category"]["version"].asInteger();
+ const LLSD& content = getContent();
+ if (!content.isMap())
+ {
+ failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content);
+ return;
+ }
+ S32 new_version = content["category"]["version"].asInteger();
LLAppearanceMgr* app_mgr = LLAppearanceMgr::getInstance();
@@ -3303,12 +3338,13 @@ public:
app_mgr->mLastUpdateRequestCOFVersion = new_version;
}
- virtual void errorWithContent(U32 pStatus, const std::string& pReason, const LLSD& content)
+
+ virtual void httpFailure()
{
- llwarns << "While attempting to increment the agent's cof we got an error with [status:"
- << pStatus << "]: " << content << llendl;
+ LL_WARNS("Avatar") << "While attempting to increment the agent's cof we got an error "
+ << dumpResponse() << LL_ENDL;
F32 seconds_to_wait;
- if (mRetryPolicy->shouldRetry(pStatus,seconds_to_wait))
+ if (mRetryPolicy->shouldRetry(getStatus(), getResponseHeaders(), seconds_to_wait))
{
llinfos << "retrying" << llendl;
doAfterInterval(boost::bind(&LLAppearanceMgr::incrementCofVersion,
@@ -3322,6 +3358,7 @@ public:
}
}
+private:
LLPointer<LLHTTPRetryPolicy> mRetryPolicy;
};