From 6b7408178bf9cb3864cec14408d78e8374f26b68 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 1 Mar 2011 17:08:02 -0500 Subject: [PATCH 1/2] Avoid spurious bwhist parsing failures This should fix a bug that special ran into, where if your state file didn't record period maxima, it would never decide that it had successfully parsed itself unless you got lucky with your uninitialized-variable values. This patch also tries to improve error messags in the case where a maximum value legitimately doesn't parse. --- src/or/rephist.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/or/rephist.c b/src/or/rephist.c index 3f4a70418..61ae2c317 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -1602,18 +1602,24 @@ rep_hist_load_bwhist_state_section(bw_array_t *b, b->cur_obs_time = start; b->next_period = start + NUM_SECS_BW_SUM_INTERVAL; SMARTLIST_FOREACH_BEGIN(s_values, const char *, cp) { + const char *maxstr = NULL; v = tor_parse_uint64(cp, 10, 0, UINT64_MAX, &ok, NULL); if (have_maxima) { - const char *maxstr = smartlist_get(s_maxima, cp_sl_idx); + maxstr = smartlist_get(s_maxima, cp_sl_idx); mv = tor_parse_uint64(maxstr, 10, 0, UINT64_MAX, &ok_m, NULL); mv *= NUM_SECS_ROLLING_MEASURE; } else { /* No maxima known; guess average rate to be conservative. */ mv = v / s_interval; } - if (!ok || !ok_m) { + if (!ok) { retval = -1; - log_notice(LD_HIST, "Could not parse '%s' into a number.'", cp); + log_notice(LD_HIST, "Could not parse value '%s' into a number.'",cp); + } + if (maxstr && !ok_m) { + retval = -1; + log_notice(LD_HIST, "Could not parse maximum '%s' into a number.'", + maxstr); } if (start < now) { From 88e0de9ebbb75a64d7870ccd8cf431bb0f23c937 Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Thu, 3 Mar 2011 10:41:39 -0800 Subject: [PATCH 2/2] Fix typo in man page --- doc/tor.1.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/tor.1.txt b/doc/tor.1.txt index 8b8fd202b..f1734d201 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -34,7 +34,7 @@ OPTIONS Display a short help message and exit. **-f** __FILE__:: - FILE contains further "option value" paris. (Default: @CONFDIR@/torrc) + FILE contains further "option value" pairs. (Default: @CONFDIR@/torrc) **--hash-password**:: Generates a hashed password for control port access.