From 6aeca5237d3e801cc6da07a83af22bb159be703b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 2 Nov 2007 04:18:28 +0000 Subject: [PATCH] r14631@tombo: nickm | 2007-11-02 00:18:17 -0400 Better log messages for "not enough to build a circuit" message. svn:r12324 --- ChangeLog | 1 + src/or/main.c | 2 +- src/or/or.h | 1 + src/or/routerlist.c | 31 ++++++++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6404ef16b..0d71e3ff95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,6 +44,7 @@ Changes in version 0.2.0.10-alpha - 2007-1?-?? - Authorities send back an X-Descriptor-Not-New header in response to an accepted-but-discarded descriptor upload. Partially implements fix for bug 535. + - Make the "not enough dir info yet" message better. o Minor features (controller): - When reporting clock skew, and we only have a lower bound on the amount diff --git a/src/or/main.c b/src/or/main.c index 7a7fc53217..b7787f7ef2 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -659,7 +659,7 @@ directory_info_has_arrived(time_t now, int from_cache) if (!router_have_minimum_dir_info()) { log(LOG_NOTICE, LD_DIR, "I learned some more directory information, but not enough to " - "build a circuit."); + "build a circuit: %s", get_dir_info_status_string()); update_router_descriptor_downloads(now); return; } else { diff --git a/src/or/or.h b/src/or/or.h index 2a8cd64417..04f94602b9 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3769,6 +3769,7 @@ void update_router_descriptor_downloads(time_t now); void update_extrainfo_downloads(time_t now); int router_have_minimum_dir_info(void); void router_dir_info_changed(void); +const char *get_dir_info_status_string(void); void router_reset_descriptor_download_failures(void); int router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2); int routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei, diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 0b4500248f..9ed50c459d 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -3845,6 +3845,8 @@ static int have_min_dir_info = 0; * enough directory info to build circuits that our old answer can no longer * be trusted. */ static int need_to_update_have_min_dir_info = 1; +/** DOCDOC */ +static char dir_info_status[128] = ""; /** Return true iff we have enough networkstatus and router information to * start building circuits. Right now, this means "more than half the @@ -3870,6 +3872,13 @@ router_dir_info_changed(void) need_to_update_have_min_dir_info = 1; } +/** DOCDOC */ +const char * +get_dir_info_status_string(void) +{ + return dir_info_status; +} + /** Change the value of have_min_dir_info, setting it true iff we have enough * network and router information to build circuits. Clear the value of * need_to_update_have_min_dir_info. */ @@ -3884,12 +3893,19 @@ update_router_have_minimum_dir_info(void) networkstatus_get_reasonably_live_consensus(now); if (!consensus) { + if (!networkstatus_get_latest_consensus()) + strlcpy(dir_info_status, "We have no network-status document.", + sizeof(dir_info_status)); + else + strlcpy(dir_info_status, "We have no recent network-status document.", + sizeof(dir_info_status)); res = 0; goto done; } if (should_delay_dir_fetches(get_options())) { log_notice(LD_DIR, "no known bridge descriptors running yet; stalling"); + strlcpy(dir_info_status, "No bridge descriptors.", sizeof(dir_info_status)); res = 0; goto done; } @@ -3903,7 +3919,19 @@ update_router_have_minimum_dir_info(void) } } }); - res = num_present >= num_usable/4 && num_usable > 2; + + if (num_present < num_usable/4) { + tor_snprintf(dir_info_status, sizeof(dir_info_status), + "We have only %d/%d usable descriptors.", num_present, num_usable); + res = 0; + } else if (num_usable < 2) { + tor_snprintf(dir_info_status, sizeof(dir_info_status), + "Only %d usable descriptor%s known!", num_usable, + num_usable ? "" : "s"); + res = 0; + } else { + res = 1; + } done: if (res && !have_min_dir_info) { @@ -3919,6 +3947,7 @@ update_router_have_minimum_dir_info(void) control_event_client_status(LOG_NOTICE, "NOT_ENOUGH_DIR_INFO"); } have_min_dir_info = res; + need_to_update_have_min_dir_info = 0; } /** Reset the descriptor download failure count on all routers, so that we