[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r12324: Better log messages for "not enough to build a circuit" mess (in tor/trunk: . src/or)



Author: nickm
Date: 2007-11-02 00:18:28 -0400 (Fri, 02 Nov 2007)
New Revision: 12324

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/main.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/routerlist.c
Log:
 r14631@tombo:  nickm | 2007-11-02 00:18:17 -0400
 Better log messages for "not enough to build a circuit" message.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r14631] on d9e39d38-0f13-419c-a857-e10a0ce2aa0c

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-11-02 03:21:54 UTC (rev 12323)
+++ tor/trunk/ChangeLog	2007-11-02 04:18:28 UTC (rev 12324)
@@ -44,6 +44,7 @@
     - 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

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-11-02 03:21:54 UTC (rev 12323)
+++ tor/trunk/src/or/main.c	2007-11-02 04:18:28 UTC (rev 12324)
@@ -659,7 +659,7 @@
   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 {

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-11-02 03:21:54 UTC (rev 12323)
+++ tor/trunk/src/or/or.h	2007-11-02 04:18:28 UTC (rev 12324)
@@ -3769,6 +3769,7 @@
 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,

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-11-02 03:21:54 UTC (rev 12323)
+++ tor/trunk/src/or/routerlist.c	2007-11-02 04:18:28 UTC (rev 12324)
@@ -3845,6 +3845,8 @@
  * 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 @@
   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 @@
     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,8 +3919,20 @@
          }
        }
      });
-  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) {
     log(LOG_NOTICE, LD_DIR,
@@ -3919,6 +3947,7 @@
     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