[tor-commits] [tor/master] Don't initialize desc stats for non-bridgedirauth nodes

nickm at torproject.org nickm at torproject.org
Mon Oct 24 14:21:17 UTC 2011


commit f885c605013bd72970159aad92ad9d9f64395a0c
Author: Sebastian Hahn <sebastian at torproject.org>
Date:   Mon Oct 24 12:51:00 2011 +0200

    Don't initialize desc stats for non-bridgedirauth nodes
    
    Also make sure that calling rep_hist_note_desc_served() while stats
    aren't initialized just returns.
    
    Bug spotted by SwissTorHelp. Thanks!
---
 src/or/config.c  |    3 ++-
 src/or/rephist.c |    2 ++
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index 627e1ac..40ce258 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1578,7 +1578,8 @@ options_act(const or_options_t *old_options)
         options->ConnDirectionStatistics) {
       rep_hist_conn_stats_init(now);
     }
-    if (!old_options || !old_options->BridgeAuthoritativeDir) {
+    if ((!old_options || !old_options->BridgeAuthoritativeDir) &&
+        options->BridgeAuthoritativeDir) {
       rep_hist_desc_stats_init(now);
       print_notice = 1;
     }
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 1aa0aeb..f8ebe64 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -2712,6 +2712,8 @@ rep_hist_desc_stats_write(time_t now)
 void
 rep_hist_note_desc_served(const char * desc)
 {
+  if (!served_descs)
+    return; // We're not collecting stats
   digestmap_set(served_descs, desc, (void *)1);
   total_descriptor_downloads++;
 }





More information about the tor-commits mailing list