diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-05-15 08:33:08 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-05-15 08:33:08 -0400 |
commit | 009453f919825c40ad12b2b89c8754bcb53fa8f9 (patch) | |
tree | 65892f60c0914c63c37e4947973e1f779ebf9cc1 /src | |
parent | ee1b8196d372a1a407b3e4bd23e9860376330e69 (diff) | |
parent | ad61282f0c46e4b19b92e0a7ab2e2beec75acf97 (diff) | |
download | tor-009453f919825c40ad12b2b89c8754bcb53fa8f9.tar.gz tor-009453f919825c40ad12b2b89c8754bcb53fa8f9.zip |
Merge remote-tracking branch 'linus/task-5891'
Diffstat (limited to 'src')
-rw-r--r-- | src/or/rephist.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index 0cd60eeb83..59e08e59fb 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -2650,24 +2650,30 @@ rep_hist_format_desc_stats(time_t now) const char *key; void *val; unsigned size; - int *vals; + int *vals, max = 0, q3 = 0, md = 0, q1 = 0, min = 0; int n = 0; if (!start_of_served_descs_stats_interval) return NULL; - size = digestmap_size(served_descs); - if (size == 0) - return NULL; - vals = tor_malloc(size * sizeof(int)); - - for (iter = digestmap_iter_init(served_descs); !digestmap_iter_done(iter); - iter = digestmap_iter_next(served_descs, iter) ) { - uintptr_t count; - digestmap_iter_get(iter, &key, &val); - count = (uintptr_t)val; - vals[n++] = (int)count; - (void)key; + size = digestmap_size(served_descs); + if (size > 0) { + vals = tor_malloc(size * sizeof(int)); + for (iter = digestmap_iter_init(served_descs); + !digestmap_iter_done(iter); + iter = digestmap_iter_next(served_descs, iter)) { + uintptr_t count; + digestmap_iter_get(iter, &key, &val); + count = (uintptr_t)val; + vals[n++] = (int)count; + (void)key; + } + max = find_nth_int(vals, size, size-1); + q3 = find_nth_int(vals, size, (3*size-1)/4); + md = find_nth_int(vals, size, (size-1)/2); + q1 = find_nth_int(vals, size, (size-1)/4); + min = find_nth_int(vals, size, 0); + tor_free(vals); } format_iso_time(t, now); @@ -2678,14 +2684,8 @@ rep_hist_format_desc_stats(time_t now) t, (unsigned) (now - start_of_served_descs_stats_interval), total_descriptor_downloads, - size, - find_nth_int(vals, size, size-1), - find_nth_int(vals, size, (3*size-1)/4), - find_nth_int(vals, size, (size-1)/2), - find_nth_int(vals, size, (size-1)/4), - find_nth_int(vals, size, 0)); - - tor_free(vals); + size, max, q3, md, q1, min); + return result; } @@ -2705,6 +2705,7 @@ rep_hist_desc_stats_write(time_t now) return start_of_served_descs_stats_interval + WRITE_STATS_INTERVAL; str = rep_hist_format_desc_stats(now); + tor_assert(str != NULL); statsdir = get_datadir_fname("stats"); if (check_private_dir(statsdir, CPD_CREATE, get_options()->User) < 0) { |