summaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2011-10-21 17:01:38 +0200
committerNick Mathewson <nickm@torproject.org>2011-10-21 11:21:42 -0400
commit42b96a041de39399a60a622329c5d5ecf593ab99 (patch)
treed0e723f105d9831707f2f72d26229e9b8343d1f7 /src/or/rephist.c
parent03c06b629fc604030393567ec05c16f813d43529 (diff)
downloadtor-42b96a041de39399a60a622329c5d5ecf593ab99.tar.gz
tor-42b96a041de39399a60a622329c5d5ecf593ab99.zip
Check for jumping clock in *format_*stats functions
None of these were real bugs (yet), because the callers made sure everything was fine. Make it more explicit. Suggested by Nick
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 8038bf48a5..1aa0aeb2ac 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -2114,7 +2114,8 @@ _compare_int(const void *x, const void *y)
}
/** Return a newly allocated string containing the exit port statistics
- * until <b>now</b>, or NULL if we're not collecting exit stats. */
+ * until <b>now</b>, or NULL if we're not collecting exit stats. Caller
+ * must ensure start_of_exit_stats_interval is in the past. */
char *
rep_hist_format_exit_stats(time_t now)
{
@@ -2133,6 +2134,8 @@ rep_hist_format_exit_stats(time_t now)
if (!start_of_exit_stats_interval)
return NULL; /* Not initialized. */
+ tor_assert(now >= start_of_exit_stats_interval);
+
/* Go through all ports to find the n ports that saw most written and
* read bytes.
*
@@ -2456,7 +2459,8 @@ rep_hist_reset_buffer_stats(time_t now)
}
/** Return a newly allocated string containing the buffer statistics until
- * <b>now</b>, or NULL if we're not collecting buffer stats. */
+ * <b>now</b>, or NULL if we're not collecting buffer stats. Caller must
+ * ensure start_of_buffer_stats_interval is in the past. */
char *
rep_hist_format_buffer_stats(time_t now)
{
@@ -2475,6 +2479,8 @@ rep_hist_format_buffer_stats(time_t now)
if (!start_of_buffer_stats_interval)
return NULL; /* Not initialized. */
+ tor_assert(now >= start_of_buffer_stats_interval);
+
/* Calculate deciles if we saw at least one circuit. */
memset(processed_cells, 0, SHARES * sizeof(int));
memset(circs_in_share, 0, SHARES * sizeof(int));
@@ -2874,7 +2880,8 @@ rep_hist_note_or_conn_bytes(uint64_t conn_id, size_t num_read,
}
/** Return a newly allocated string containing the connection statistics
- * until <b>now</b>, or NULL if we're not collecting conn stats. */
+ * until <b>now</b>, or NULL if we're not collecting conn stats. Caller must
+ * ensure start_of_conn_stats_interval is in the past. */
char *
rep_hist_format_conn_stats(time_t now)
{
@@ -2883,6 +2890,8 @@ rep_hist_format_conn_stats(time_t now)
if (!start_of_conn_stats_interval)
return NULL; /* Not initialized. */
+ tor_assert(now >= start_of_conn_stats_interval);
+
format_iso_time(written, now);
tor_asprintf(&result, "conn-bi-direct %s (%d s) %d,%d,%d,%d\n",
written,