[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Fix desc stats on bridge authorities that didn't serve anything.
commit 57359b533673961fe15184b69bcedeb219c9dd90
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue May 15 12:39:08 2012 +0200
Fix desc stats on bridge authorities that didn't serve anything.
---
changes/task-5891 | 5 +++++
src/or/rephist.c | 42 +++++++++++++++++++++---------------------
2 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/changes/task-5891 b/changes/task-5891
new file mode 100644
index 0000000..79ee002
--- /dev/null
+++ b/changes/task-5891
@@ -0,0 +1,5 @@
+ o Minor bugfixes:
+ - Fix a bug where a bridge authority crashes if it has seen no
+ directory requests when it's time to write statistics to disk.
+ Fixes #5508 and #5891.
+
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 0cd60ee..173a770 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;
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits