aboutsummaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-01-10 13:15:51 -0500
committerNick Mathewson <nickm@torproject.org>2011-01-10 13:15:51 -0500
commit28844c8403f16f184c185798c78dcd6a959450a3 (patch)
treefd877ec5a41e90c703bdaf752ee890d66ac1e9e7 /src/or/rephist.c
parent7e1502c0d1aa0875fba0b26ddcf021bdfa5e11a0 (diff)
downloadtor-28844c8403f16f184c185798c78dcd6a959450a3.tar.gz
tor-28844c8403f16f184c185798c78dcd6a959450a3.zip
On bwhist state load failure, clear dir_read/write hist too
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 5a3a15edbc..f0dd45128c 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -1293,10 +1293,15 @@ static bw_array_t *dir_read_array = NULL;
directory protocol. */
static bw_array_t *dir_write_array = NULL;
-/** Set up [dir-]read_array and [dir-]write_array. */
+/** Set up [dir-]read_array and [dir-]write_array, freeing them if they alrady
+ * exist. */
static void
bw_arrays_init(void)
{
+ tor_free(read_array);
+ tor_free(write_array);
+ tor_free(dir_read_array);
+ tor_free(dir_write_array);
read_array = bw_array_new();
write_array = bw_array_new();
dir_read_array = bw_array_new();
@@ -1627,11 +1632,7 @@ rep_hist_load_state(or_state_t *state, char **err)
if (!all_ok) {
*err = tor_strdup("Parsing of bandwidth history values failed");
/* and create fresh arrays */
- tor_free(read_array);
- tor_free(write_array);
-
- read_array = bw_array_new();
- write_array = bw_array_new();
+ bw_arrays_init();
return -1;
}
return 0;