diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-11-15 16:43:50 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-11-15 16:43:50 -0500 |
commit | 8569166c70f99bf908e78ce272e71eb60cdc84d0 (patch) | |
tree | 742aa0d959932c9e22cdacbf23e8d700360adbb0 /src/or/router.c | |
parent | 7f042cbc0a9397c1e5c0f3e9c3bb31ff333d9983 (diff) | |
parent | 81f4223329a709e5138532b037a58c118b30dd7f (diff) | |
download | tor-8569166c70f99bf908e78ce272e71eb60cdc84d0.tar.gz tor-8569166c70f99bf908e78ce272e71eb60cdc84d0.zip |
Merge remote-tracking branch 'public/bug24104_029_squashed' into maint-0.2.9
Resolved conflicts with the 26269 fix in 015fcd0e1191aa6f.
Diffstat (limited to 'src/or/router.c')
-rw-r--r-- | src/or/router.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/or/router.c b/src/or/router.c index 35b6bd203c..c416474226 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -2426,22 +2426,38 @@ mark_my_descriptor_dirty(const char *reason) * if our previous bandwidth estimate was exactly 0. */ #define MAX_BANDWIDTH_CHANGE_FREQ (3*60*60) +/** Maximum uptime to republish our descriptor because of large shifts in + * 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. If so, mark our descriptor dirty. */ + * bandwidth while the uptime is smaller than MAX_UPTIME_BANDWIDTH_CHANGE. + * If so, mark our descriptor dirty. */ void check_descriptor_bandwidth_changed(time_t now) { static time_t last_changed = 0; uint64_t prev, cur; const routerinfo_t *my_ri = router_get_my_routerinfo(); + + int hibernating = we_are_hibernating(); + + /* If the relay uptime is bigger than MAX_UPTIME_BANDWIDTH_CHANGE, + * the next regularly scheduled descriptor update (18h) will be enough */ + if (get_uptime() > MAX_UPTIME_BANDWIDTH_CHANGE && !hibernating) + return; + if (!my_ri) /* make sure routerinfo exists */ return; prev = my_ri->bandwidthcapacity; - cur = we_are_hibernating() ? 0 : rep_hist_bandwidth_assess(); + cur = 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."); @@ -3640,4 +3656,3 @@ router_get_all_orports(const routerinfo_t *ri) fake_node.ri = (routerinfo_t *)ri; return node_get_all_orports(&fake_node); } - |