Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Unified Diff: net/base/backoff_entry.cc

Issue 337803004: Backoff: Respect maximum delay in face of float overflow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/backoff_entry_unittest.cc » ('j') | net/base/backoff_entry_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/backoff_entry.cc
diff --git a/net/base/backoff_entry.cc b/net/base/backoff_entry.cc
index b1826b7af469b4d72cfccd6ad849173ceb1f24fe..43037f6d2f89144d6d9b2aa3a150d8dcff1c01f4 100644
--- a/net/base/backoff_entry.cc
+++ b/net/base/backoff_entry.cc
@@ -134,6 +134,10 @@ base::TimeTicks BackoffEntry::CalculateReleaseTime() const {
// effective_failure_count - 1) * Uniform(1 - jitter_factor, 1]
double delay = policy_->initial_delay_ms;
delay *= pow(policy_->multiply_factor, effective_failure_count - 1);
+ if (isinf(delay)) {
+ delay = std::max(policy_->maximum_backoff_ms,
cbentzel 2014/06/14 15:16:07 maximum_backoff_ms is not always set - so it seems
cbentzel 2014/06/14 15:30:47 Actually, we'd reach integral overflow with this a
Ryan Sleevi 2014/06/16 17:20:47 ^ base/basictypes.h has kint64max / kint64min
Nicolas Zea 2014/06/16 20:27:25 Switched to doing all overflow checking via Checke
+ static_cast<int64>(policy_->initial_delay_ms));
+ }
delay -= base::RandDouble() * policy_->jitter_factor * delay;
const int64 kMaxInt64 = std::numeric_limits<int64>::max();
« no previous file with comments | « no previous file | net/base/backoff_entry_unittest.cc » ('j') | net/base/backoff_entry_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698