aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorjuga0 <juga@riseup.net>2018-06-03 09:40:57 +0000
committerNick Mathewson <nickm@torproject.org>2018-09-01 18:47:20 -0400
commit6210d568ecc5c2fd1833126d68505f42e4399820 (patch)
tree631d1c09672c027fc7ba159afc002f7bdc50322f /src/or
parent7d70f67deaeea1a3dc80a763f13bcec5d7a2425d (diff)
downloadtor-6210d568ecc5c2fd1833126d68505f42e4399820.tar.gz
tor-6210d568ecc5c2fd1833126d68505f42e4399820.zip
Make bandwidth change factor a constant
used to determine large changes in bandwidth.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/router.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/or/router.c b/src/or/router.c
index ab916fb6e6..4afba65491 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -2429,6 +2429,9 @@ mark_my_descriptor_dirty(const char *reason)
* estimated bandwidth. */
#define MAX_UPTIME_BANDWIDTH_CHANGE (24*60*60)
+/** By which factor bandwidth shifts have to change to be considered large. */
+#define BANDWIDTH_CHANGE_FACTOR 2
+
/** Check whether bandwidth has changed a lot since the last time we announced
* bandwidth while the uptime is smaller than MAX_UPTIME_BANDWIDTH_CHANGE.
* If so, mark our descriptor dirty. */
@@ -2449,8 +2452,8 @@ check_descriptor_bandwidth_changed(time_t now)
prev = router_get_my_routerinfo()->bandwidthcapacity;
cur = we_are_hibernating() ? 0 : rep_hist_bandwidth_assess();
if ((prev != cur && (!prev || !cur)) ||
- cur > prev*2 ||
- cur < prev/2) {
+ cur > (prev * BANDWIDTH_CHANGE_FACTOR) ||
+ cur < (prev / BANDWIDTH_CHANGE_FACTOR) ) {
if (last_changed+MAX_BANDWIDTH_CHANGE_FREQ < now || !prev) {
log_info(LD_GENERAL,
"Measured bandwidth has changed; rebuilding descriptor.");