From 9dfb8845229ed66efb2222b8dec6c624f8adb7c9 Mon Sep 17 00:00:00 2001 From: Karsten Loesing Date: Tue, 9 Nov 2010 14:18:00 +0100 Subject: [PATCH 1/2] Turn on directory request statistics by default. Change the default values for collecting directory request statistics and inlcuding them in extra-info descriptors to 1. Don't break if we are configured to collect directory request or entry statistics and don't have a GeoIP database. Instead, print out a notice and skip initializing the affected statistics code. This is the cherry-picked 499661524b0a572303087af721325608dd91f7ce. --- changes/dirreq-stats-default | 4 +++ src/or/config.c | 63 ++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 changes/dirreq-stats-default diff --git a/changes/dirreq-stats-default b/changes/dirreq-stats-default new file mode 100644 index 0000000000..673be6af13 --- /dev/null +++ b/changes/dirreq-stats-default @@ -0,0 +1,4 @@ + o Minor features: + - Turn on directory request statistics by default and include them in + extra-info descriptors. Don't break if we have no GeoIP database. + diff --git a/src/or/config.c b/src/or/config.c index 8972506477..230ccf25c0 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -229,7 +229,7 @@ static config_var_t _option_vars[] = { OBSOLETE("DirRecordUsageGranularity"), OBSOLETE("DirRecordUsageRetainIPs"), OBSOLETE("DirRecordUsageSaveInterval"), - V(DirReqStatistics, BOOL, "0"), + V(DirReqStatistics, BOOL, "1"), VAR("DirServer", LINELIST, DirServers, NULL), V(DisableAllSwap, BOOL, "0"), V(DNSPort, PORT, "0"), @@ -246,7 +246,7 @@ static config_var_t _option_vars[] = { V(ExitPolicy, LINELIST, NULL), V(ExitPolicyRejectPrivate, BOOL, "1"), V(ExitPortStatistics, BOOL, "0"), - V(ExtraInfoStatistics, BOOL, "0"), + V(ExtraInfoStatistics, BOOL, "1"), #if defined (WINCE) V(FallbackNetworkstatusFile, FILENAME, "fallback-consensus"), @@ -1408,44 +1408,45 @@ options_act(or_options_t *old_options) tor_free(actual_fname); } - if (options->DirReqStatistics && !geoip_is_loaded()) { - /* Check if GeoIP database could be loaded. */ - log_warn(LD_CONFIG, "Configured to measure directory request " - "statistics, but no GeoIP database found!"); - return -1; - } - - if (options->EntryStatistics) { - if (should_record_bridge_info(options)) { - /* Don't allow measuring statistics on entry guards when configured - * as bridge. */ - log_warn(LD_CONFIG, "Bridges cannot be configured to measure " - "additional GeoIP statistics as entry guards."); - return -1; - } else if (!geoip_is_loaded()) { - /* Check if GeoIP database could be loaded. */ - log_warn(LD_CONFIG, "Configured to measure entry node statistics, " - "but no GeoIP database found!"); - return -1; - } - } - if (options->CellStatistics || options->DirReqStatistics || options->EntryStatistics || options->ExitPortStatistics) { time_t now = time(NULL); + int print_notice = 0; if ((!old_options || !old_options->CellStatistics) && - options->CellStatistics) + options->CellStatistics) { rep_hist_buffer_stats_init(now); + print_notice = 1; + } if ((!old_options || !old_options->DirReqStatistics) && - options->DirReqStatistics) - geoip_dirreq_stats_init(now); + options->DirReqStatistics) { + if (geoip_is_loaded()) { + geoip_dirreq_stats_init(now); + print_notice = 1; + } else { + log_notice(LD_CONFIG, "Configured to measure directory request " + "statistics, but no GeoIP database found! " + "Please specify a GeoIP database using the " + "GeoIPFile option!"); + } + } if ((!old_options || !old_options->EntryStatistics) && - options->EntryStatistics) - geoip_entry_stats_init(now); + options->EntryStatistics && !should_record_bridge_info(options)) { + if (geoip_is_loaded()) { + geoip_entry_stats_init(now); + print_notice = 1; + } else { + log_notice(LD_CONFIG, "Configured to measure entry node " + "statistics, but no GeoIP database found! " + "Please specify a GeoIP database using the " + "GeoIPFile option!"); + } + } if ((!old_options || !old_options->ExitPortStatistics) && - options->ExitPortStatistics) + options->ExitPortStatistics) { rep_hist_exit_stats_init(now); - if (!old_options) + print_notice = 1; + } + if (print_notice) log_notice(LD_CONFIG, "Configured to measure statistics. Look for " "the *-stats files that will first be written to the " "data directory in 24 hours from now."); From f37d24c550a0d8512249f77262c01960af6ed31b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 7 Oct 2011 16:47:43 -0400 Subject: [PATCH 2/2] Note ticket and source version for feature3951 in changes file --- changes/dirreq-stats-default | 1 + 1 file changed, 1 insertion(+) diff --git a/changes/dirreq-stats-default b/changes/dirreq-stats-default index 673be6af13..df7ac11425 100644 --- a/changes/dirreq-stats-default +++ b/changes/dirreq-stats-default @@ -1,4 +1,5 @@ o Minor features: - Turn on directory request statistics by default and include them in extra-info descriptors. Don't break if we have no GeoIP database. + Backported from 0.2.3.1-alpha; implements ticket 3951.