aboutsummaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2009-12-03 10:51:51 +0100
committerKarsten Loesing <karsten.loesing@gmx.net>2009-12-03 10:51:51 +0100
commit16fbb2f745bf0a910e7f7d6ae101dec6cbc195fe (patch)
tree8758fcdfae15d67f63cc4c317fa4c4e9a0a24057 /src/or/rephist.c
parent0faf5c5fd258ddc65282d6025e70c10226148045 (diff)
downloadtor-16fbb2f745bf0a910e7f7d6ae101dec6cbc195fe.tar.gz
tor-16fbb2f745bf0a910e7f7d6ae101dec6cbc195fe.zip
Minor fix to buffer stats.
Do not segfault when writing buffer stats when we haven't observed a single circuit to report about. This is a minor bug that would only show up in testing environments with no traffic and with reduced stats intervals.
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 1ff9cde69f..003e082d58 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -2701,9 +2701,16 @@ rep_hist_buffer_stats_write(time_t now)
memset(circs_in_share, 0, SHARES * sizeof(int));
memset(queued_cells, 0, SHARES * sizeof(double));
memset(time_in_queue, 0, SHARES * sizeof(double));
+ if (!circuits_for_buffer_stats)
+ circuits_for_buffer_stats = smartlist_create();
smartlist_sort(circuits_for_buffer_stats,
_buffer_stats_compare_entries);
number_of_circuits = smartlist_len(circuits_for_buffer_stats);
+ if (number_of_circuits < 1) {
+ log_info(LD_HIST, "Attempt to write cell statistics to disk failed. "
+ "We haven't seen a single circuit to report about.");
+ goto done;
+ }
i = 0;
SMARTLIST_FOREACH_BEGIN(circuits_for_buffer_stats,
circ_buffer_stats_t *, stat)