summaryrefslogtreecommitdiff
path: root/indra/llcorehttp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2017-10-11 09:13:55 -0400
committerOz Linden <oz@lindenlab.com>2017-10-11 09:13:55 -0400
commitd62ad1ef8afc1b9abadbc611d373a7a7d9afc368 (patch)
tree9f14b141e692c3b78eee846f12fc021feacf1de6 /indra/llcorehttp
parentc0ac11e24022eb51918e825414f2c04f3085bc61 (diff)
parentb6d22de58850fc9a5b34eeb5b7930e5845bfc42d (diff)
merge changes for 5.0.8-release
Diffstat (limited to 'indra/llcorehttp')
-rw-r--r--indra/llcorehttp/_httpinternal.h5
-rw-r--r--indra/llcorehttp/_httpoprequest.cpp5
-rw-r--r--indra/llcorehttp/_httpoprequest.h2
-rw-r--r--indra/llcorehttp/_httppolicy.cpp16
-rw-r--r--indra/llcorehttp/httpoptions.cpp12
-rw-r--r--indra/llcorehttp/httpoptions.h22
6 files changed, 50 insertions, 12 deletions
diff --git a/indra/llcorehttp/_httpinternal.h b/indra/llcorehttp/_httpinternal.h
index 79c89d6c92..690ebbecd8 100644
--- a/indra/llcorehttp/_httpinternal.h
+++ b/indra/llcorehttp/_httpinternal.h
@@ -127,9 +127,12 @@ const int HTTP_TRACE_MAX = HTTP_TRACE_CURL_BODIES;
// We want to span a few windows to allow transport to slow
// after onset of the throttles and then recover without a final
// failure. Other systems may need other constants.
-const int HTTP_RETRY_COUNT_DEFAULT = 8;
+const int HTTP_RETRY_COUNT_DEFAULT = 5;
const int HTTP_RETRY_COUNT_MIN = 0;
const int HTTP_RETRY_COUNT_MAX = 100;
+const HttpTime HTTP_RETRY_BACKOFF_MIN_DEFAULT = 1E6L; // 1 sec
+const HttpTime HTTP_RETRY_BACKOFF_MAX_DEFAULT = 5E6L; // 5 sec
+const HttpTime HTTP_RETRY_BACKOFF_MAX = 20E6L; // 20 sec
const int HTTP_REDIRECTS_DEFAULT = 10;
diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp
index 07cc0e4625..fceed8524b 100644
--- a/indra/llcorehttp/_httpoprequest.cpp
+++ b/indra/llcorehttp/_httpoprequest.cpp
@@ -140,6 +140,8 @@ HttpOpRequest::HttpOpRequest()
mPolicy503Retries(0),
mPolicyRetryAt(HttpTime(0)),
mPolicyRetryLimit(HTTP_RETRY_COUNT_DEFAULT),
+ mPolicyMinRetryBackoff(HttpTime(HTTP_RETRY_BACKOFF_MIN_DEFAULT)),
+ mPolicyMaxRetryBackoff(HttpTime(HTTP_RETRY_BACKOFF_MAX_DEFAULT)),
mCallbackSSLVerify(NULL)
{
// *NOTE: As members are added, retry initialization/cleanup
@@ -434,6 +436,9 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id,
mPolicyRetryLimit = options->getRetries();
mPolicyRetryLimit = llclamp(mPolicyRetryLimit, HTTP_RETRY_COUNT_MIN, HTTP_RETRY_COUNT_MAX);
mTracing = (std::max)(mTracing, llclamp(options->getTrace(), HTTP_TRACE_MIN, HTTP_TRACE_MAX));
+
+ mPolicyMinRetryBackoff = llclamp(options->getMinBackoff(), HttpTime(0), HTTP_RETRY_BACKOFF_MAX);
+ mPolicyMaxRetryBackoff = llclamp(options->getMaxBackoff(), mPolicyMinRetryBackoff, HTTP_RETRY_BACKOFF_MAX);
}
}
diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h
index dbcc57d0fd..43d49324af 100644
--- a/indra/llcorehttp/_httpoprequest.h
+++ b/indra/llcorehttp/_httpoprequest.h
@@ -232,6 +232,8 @@ public:
int mPolicy503Retries;
HttpTime mPolicyRetryAt;
int mPolicyRetryLimit;
+ HttpTime mPolicyMinRetryBackoff; // initial delay between retries (mcs)
+ HttpTime mPolicyMaxRetryBackoff;
}; // end class HttpOpRequest
diff --git a/indra/llcorehttp/_httppolicy.cpp b/indra/llcorehttp/_httppolicy.cpp
index b2709b53ec..4889cac9bf 100644
--- a/indra/llcorehttp/_httppolicy.cpp
+++ b/indra/llcorehttp/_httppolicy.cpp
@@ -151,20 +151,16 @@ void HttpPolicy::addOp(const HttpOpRequest::ptr_t &op)
void HttpPolicy::retryOp(const HttpOpRequest::ptr_t &op)
{
- static const HttpTime retry_deltas[] =
- {
- 250000, // 1st retry in 0.25 S, etc...
- 500000,
- 1000000,
- 2000000,
- 5000000 // ... to every 5.0 S.
- };
- static const int delta_max(int(LL_ARRAY_SIZE(retry_deltas)) - 1);
static const HttpStatus error_503(503);
const HttpTime now(totalTime());
const int policy_class(op->mReqPolicy);
- HttpTime delta(retry_deltas[llclamp(op->mPolicyRetries, 0, delta_max)]);
+
+ HttpTime delta_min = op->mPolicyMinRetryBackoff;
+ HttpTime delta_max = op->mPolicyMaxRetryBackoff;
+ // mPolicyRetries limited to 100
+ U32 delta_factor = op->mPolicyRetries <= 10 ? 1 << op->mPolicyRetries : 1024;
+ HttpTime delta = llmin(delta_min * delta_factor, delta_max);
bool external_delta(false);
if (op->mReplyRetryAfter > 0 && op->mReplyRetryAfter < 30)
diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp
index aab447f2dd..df5aa52fa9 100644
--- a/indra/llcorehttp/httpoptions.cpp
+++ b/indra/llcorehttp/httpoptions.cpp
@@ -39,6 +39,8 @@ HttpOptions::HttpOptions() :
mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT),
mTransferTimeout(HTTP_REQUEST_XFER_TIMEOUT_DEFAULT),
mRetries(HTTP_RETRY_COUNT_DEFAULT),
+ mMinRetryBackoff(HTTP_RETRY_BACKOFF_MIN_DEFAULT),
+ mMaxRetryBackoff(HTTP_RETRY_BACKOFF_MAX_DEFAULT),
mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT),
mFollowRedirects(true),
mVerifyPeer(false),
@@ -81,6 +83,16 @@ void HttpOptions::setRetries(unsigned int retries)
mRetries = retries;
}
+void HttpOptions::setMinBackoff(HttpTime delay)
+{
+ mMinRetryBackoff = delay;
+}
+
+void HttpOptions::setMaxBackoff(HttpTime delay)
+{
+ mMaxRetryBackoff = delay;
+}
+
void HttpOptions::setUseRetryAfter(bool use_retry)
{
mUseRetryAfter = use_retry;
diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h
index 510eaa45bb..8a6de61b04 100644
--- a/indra/llcorehttp/httpoptions.h
+++ b/indra/llcorehttp/httpoptions.h
@@ -101,13 +101,31 @@ public:
/// Sets the number of retries on an LLCore::HTTPRequest before the
/// request fails.
- // Default: 8
+ // Default: 5
void setRetries(unsigned int retries);
unsigned int getRetries() const
{
return mRetries;
}
+ /// Sets minimal delay before request retries. In microseconds.
+ /// HttpPolicy will increase delay from min to max with each retry
+ // Default: 1 000 000 mcs
+ void setMinBackoff(HttpTime delay);
+ HttpTime getMinBackoff() const
+ {
+ return mMinRetryBackoff;
+ }
+
+ /// Sets maximum delay before request retries. In microseconds.
+ /// HttpPolicy will increase delay from min to max with each retry
+ // Default: 5 000 000 mcs
+ void setMaxBackoff(HttpTime delay);
+ HttpTime getMaxBackoff() const
+ {
+ return mMaxRetryBackoff;
+ }
+
// Default: true
void setUseRetryAfter(bool use_retry);
bool getUseRetryAfter() const
@@ -166,6 +184,8 @@ protected:
unsigned int mTimeout;
unsigned int mTransferTimeout;
unsigned int mRetries;
+ HttpTime mMinRetryBackoff;
+ HttpTime mMaxRetryBackoff;
bool mUseRetryAfter;
bool mFollowRedirects;
bool mVerifyPeer;