diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-05-07 13:33:19 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-05-07 13:33:19 -0400 |
commit | 17236a58429dab6bf0536a64b90c4ec7f25985b8 (patch) | |
tree | 633b512e76ed605b47a1e42fb51b1171734e3685 /src/or | |
parent | 2c5841a8b855b6340952a10b6014ec6cdd44ca87 (diff) | |
parent | 46002aa69114d84ea244558baeef5d07f389d9fc (diff) | |
download | tor-17236a58429dab6bf0536a64b90c4ec7f25985b8.tar.gz tor-17236a58429dab6bf0536a64b90c4ec7f25985b8.zip |
Merge branch 'maint-0.3.3'
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/circuitstats.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c index 9a0fb4d715..d8dc085c84 100644 --- a/src/or/circuitstats.c +++ b/src/or/circuitstats.c @@ -894,11 +894,23 @@ circuit_build_times_get_xm(circuit_build_times_t *cbt) histogram[nth_max_bin[n]]); } - /* The following assert is safe, because we don't get called when we - * haven't observed at least CBT_MIN_MIN_CIRCUITS_TO_OBSERVE circuits. */ + /* bin_counts can become zero if all of our last CBT_NCIRCUITS_TO_OBSERVE + * circuits were abandoned before they completed. This shouldn't happen, + * though. We should have reset/re-learned a lower timeout first. */ + if (bin_counts == 0) { + ret = 0; + log_warn(LD_CIRC, + "No valid circuit build time data out of %d times, %u modes, " + "have_timeout=%d, %lfms", cbt->total_build_times, num_modes, + cbt->have_computed_timeout, cbt->timeout_ms); + goto done; + } + tor_assert(bin_counts > 0); ret /= bin_counts; + + done: tor_free(histogram); tor_free(nth_max_bin); @@ -1184,6 +1196,10 @@ circuit_build_times_update_alpha(circuit_build_times_t *cbt) * and less frechet-like. */ cbt->Xm = circuit_build_times_get_xm(cbt); + /* If Xm came back 0, then too many circuits were abandoned. */ + if (cbt->Xm == 0) + return 0; + tor_assert(cbt->Xm > 0); for (i=0; i< CBT_NCIRCUITS_TO_OBSERVE; i++) { |