diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2013-04-12 17:04:48 -0400 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2013-04-12 17:04:48 -0400 |
commit | bb237ce15f0a7bc4a3fbffc45b1e4548fd1d2f81 (patch) | |
tree | bba6ac1e44172c6f95f46802ec189a3fe47dcd44 /indra/newview/llhttpretrypolicy.cpp | |
parent | a8cdcfc9a893b7debf7c006022b57c389b50bf0d (diff) |
SH_4061 WIP - retry policy org and tests
Diffstat (limited to 'indra/newview/llhttpretrypolicy.cpp')
-rwxr-xr-x | indra/newview/llhttpretrypolicy.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/indra/newview/llhttpretrypolicy.cpp b/indra/newview/llhttpretrypolicy.cpp index 5c6dabbe99..82f6eab00e 100755 --- a/indra/newview/llhttpretrypolicy.cpp +++ b/indra/newview/llhttpretrypolicy.cpp @@ -28,6 +28,17 @@ #include "llhttpretrypolicy.h" +LLAdaptiveRetryPolicy::LLAdaptiveRetryPolicy(F32 min_delay, F32 max_delay, F32 backoff_factor, U32 max_retries): + mMinDelay(min_delay), + mMaxDelay(max_delay), + mBackoffFactor(backoff_factor), + mMaxRetries(max_retries), + mDelay(min_delay), + mRetryCount(0), + mShouldRetry(true) +{ +} + bool LLAdaptiveRetryPolicy::getRetryAfter(const LLSD& headers, F32& retry_header_time) { return (headers.has(HTTP_IN_HEADER_RETRY_AFTER) @@ -77,6 +88,11 @@ void LLAdaptiveRetryPolicy::onFailure(const LLCore::HttpResponse *response) void LLAdaptiveRetryPolicy::onFailureCommon(S32 status, bool has_retry_header_time, F32 retry_header_time) { + if (!mShouldRetry) + { + llinfos << "keep on failing" << llendl; + return; + } if (mRetryCount > 0) { mDelay = llclamp(mDelay*mBackoffFactor,mMinDelay,mMaxDelay); @@ -111,7 +127,12 @@ void LLAdaptiveRetryPolicy::onFailureCommon(S32 status, bool has_retry_header_ti bool LLAdaptiveRetryPolicy::shouldRetry(F32& seconds_to_wait) const { - llassert(mRetryCount>0); // have to call onFailure() before shouldRetry() + if (mRetryCount == 0) + { + // Called shouldRetry before any failure. + seconds_to_wait = F32_MAX; + return false; + } seconds_to_wait = mShouldRetry ? mRetryTimer.getRemainingTimeF32() : F32_MAX; return mShouldRetry; } |