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

[or-cvs] Prevent a "try forever to download an unobtainable descript...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv8562/src/or

Modified Files:
	directory.c or.h routerlist.c routerparse.c 
Log Message:
Prevent a "try forever to download an unobtainable descriptor" bug.  Still remaining: the "give up forever" bug.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.283
retrieving revision 1.284
diff -u -d -r1.283 -r1.284
--- directory.c	16 Sep 2005 16:47:20 -0000	1.283
+++ directory.c	18 Sep 2005 02:51:12 -0000	1.284
@@ -283,7 +283,7 @@
     log_fn(LOG_INFO, "Giving up on directory server at '%s'; retrying",
            conn->address);
     connection_dir_download_networkstatus_failed(conn);
-  } else if (conn->purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS) {
+  } else if (conn->purpose == DIR_PURPOSE_FETCH_SERVERDESC) {
     log_fn(LOG_INFO, "Giving up on directory server at '%s'; retrying",
            conn->address);
     connection_dir_download_routerdesc_failed(conn);
@@ -320,7 +320,8 @@
 static void
 connection_dir_download_routerdesc_failed(connection_t *conn)
 {
-  /* try again. */
+  /* Try again. */
+  /*XXXX011 plays poorly with multiple conns. */
   update_router_descriptor_downloads(time(NULL));
 }
 
@@ -1547,7 +1548,13 @@
 static void
 dir_routerdesc_download_failed(smartlist_t *failed)
 {
-  /* XXXX writeme!  Give up after a while! */
+  SMARTLIST_FOREACH(failed, const char *, cp,
+  {
+    routerstatus_t *rs = router_get_combined_status_by_digest(cp);
+    if (!rs || rs->n_download_failures >= MAX_ROUTERDESC_DOWNLOAD_FAILURES)
+      continue;
+    ++rs->n_download_failures;
+  });
 }
 
 /* DOCDOC */

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.690
retrieving revision 1.691
diff -u -d -r1.690 -r1.691
--- or.h	18 Sep 2005 02:24:42 -0000	1.690
+++ or.h	18 Sep 2005 02:51:12 -0000	1.691
@@ -805,6 +805,9 @@
                                 * recent descriptor. */
 } routerstatus_t;
 
+/*XXXX001 make this configurable! */
+#define MAX_ROUTERDESC_DOWNLOAD_FAILURES 16
+
 /** Contents of a (v2 or later) network status object. */
 typedef struct networkstatus_t {
   /** When did we receive the network-status document? */
@@ -2107,11 +2110,13 @@
                             const char *digest, int supports_v1);
 void clear_trusted_dir_servers(void);
 networkstatus_t *networkstatus_get_by_digest(const char *digest);
+routerstatus_t *router_get_combined_status_by_digest(const char *digest);
 void update_networkstatus_cache_downloads(time_t now);
 void update_networkstatus_client_downloads(time_t now);
 void update_router_descriptor_downloads(time_t now);
 void routers_update_all_from_networkstatus(void);
-void routers_update_status_from_networkstatus(smartlist_t *routers);
+void routers_update_status_from_networkstatus(smartlist_t *routers,
+                                              int reset_failures);
 smartlist_t *router_list_superseded(void);
 int router_have_minimum_dir_info(void);
 void networkstatus_list_update_recent(time_t now);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.301
retrieving revision 1.302
diff -u -d -r1.301 -r1.302
--- routerlist.c	18 Sep 2005 02:24:42 -0000	1.301
+++ routerlist.c	18 Sep 2005 02:51:12 -0000	1.302
@@ -29,7 +29,6 @@
 static void mark_all_trusteddirservers_up(void);
 static int router_nickname_is_in_list(routerinfo_t *router, const char *list);
 static int router_nickname_matches(routerinfo_t *router, const char *nickname);
-static routerstatus_t *router_get_combined_status_by_digest(const char *d);
 static void routerstatus_list_update_from_networkstatus(time_t now);
 
 /****************************************************************************/
@@ -1292,7 +1291,7 @@
 
   router_parse_list_from_string(&s, routers);
 
-  routers_update_status_from_networkstatus(routers);
+  routers_update_status_from_networkstatus(routers, !from_cache);
 
   SMARTLIST_FOREACH(routers, routerinfo_t *, ri,
   {
@@ -1554,7 +1553,8 @@
                            _compare_digest_to_routerstatus_entry);
 }
 
-static routerstatus_t *
+/*DOCDOC*/
+routerstatus_t *
 router_get_combined_status_by_digest(const char *digest)
 {
   if (!routerstatus_list)
@@ -1563,7 +1563,6 @@
                            _compare_digest_to_routerstatus_entry);
 }
 
-
 /* XXXX These should be configurable, perhaps? NM */
 #define AUTHORITY_NS_CACHE_INTERVAL 10*60
 #define NONAUTHORITY_NS_CACHE_INTERVAL 15*60
@@ -1995,7 +1994,7 @@
   if (networkstatus_list_has_changed)
     routerstatus_list_update_from_networkstatus(now);
 
-  routers_update_status_from_networkstatus(routerlist->routers);
+  routers_update_status_from_networkstatus(routerlist->routers, 0);
 
   me = router_get_my_routerinfo();
   if (me) {
@@ -2003,7 +2002,7 @@
      * dirservers list us as named, valid, etc. */
     smartlist_t *lst = smartlist_create();
     smartlist_add(lst, me);
-    routers_update_status_from_networkstatus(lst);
+    routers_update_status_from_networkstatus(lst, 1);
     if (me->is_verified == 0) {
       log_fn(LOG_WARN, "Many directory servers list us as unverified. Please consider sending your identity fingerprint to the tor-ops.");
       have_warned_about_unverified_status = 1;
@@ -2179,7 +2178,7 @@
  * is_named, is_verified, and is_running fields according to our current
  * networkstatus_t documents. */
 void
-routers_update_status_from_networkstatus(smartlist_t *routers)
+routers_update_status_from_networkstatus(smartlist_t *routers, int reset_failures)
 {
   trusted_dir_server_t *ds;
   routerstatus_t *rs;
@@ -2198,6 +2197,9 @@
     if (!rs)
       continue;
 
+    if (reset_failures)
+      rs->n_download_failures = 0;
+
     if (!namingdir)
       router->is_named = rs->is_named;
 
@@ -2250,8 +2252,10 @@
         // log_fn(LOG_NOTICE, "No status for %s", fp);
         continue;
       }
-      if (!memcmp(ri->signed_descriptor_digest,rs->descriptor_digest,DIGEST_LEN)
-          || rs->published_on <= ri->published_on) {
+      /*XXXX001 reset max_routerdesc_download_failures somewhere! */
+      if (rs->n_download_failures >= MAX_ROUTERDESC_DOWNLOAD_FAILURES ||
+          !memcmp(ri->signed_descriptor_digest,rs->descriptor_digest,DIGEST_LEN)||
+          rs->published_on <= ri->published_on) {
         /* Same digest, or earlier. No need to download it. */
         // log_fn(LOG_NOTICE, "Up-to-date status for %s", fp);
         strmap_remove(status_map, fp);

Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerparse.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- routerparse.c	18 Sep 2005 02:22:21 -0000	1.144
+++ routerparse.c	18 Sep 2005 02:51:12 -0000	1.145
@@ -692,8 +692,6 @@
     smartlist_add(routers, router);
   }
 
-  routers_update_status_from_networkstatus(routers);
-
   smartlist_add_all(dest, routers);
 
   return 0;