[or-cvs] r9616: Fix two XXXX012 issues in routerlist.c: a possible performan (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Thu Feb 22 07:41:12 UTC 2007


Author: nickm
Date: 2007-02-22 02:41:10 -0500 (Thu, 22 Feb 2007)
New Revision: 9616

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/routerlist.c
Log:
 r11876 at catbus:  nickm | 2007-02-22 02:23:13 -0500
 Fix two XXXX012 issues in routerlist.c: a possible performance issue hasnt shown up on any profiles, so unflag it.  Stop warning when we get a router descriptor that we asked for but no longer want: just drop it (if we are not a cache) or cache if (if we are).



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11876] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-02-22 06:21:19 UTC (rev 9615)
+++ tor/trunk/ChangeLog	2007-02-22 07:41:10 UTC (rev 9616)
@@ -44,6 +44,10 @@
       machines using pthreads. (Patch from coderman.)
     - Fix switched arguments on memset in the implementation of tor_munmap()
       for systems with no mmap() call.
+    - When Tor receives a router descriptor that it asked for, but no longer
+      wants (because it has received fresh networkstatuses in the meantime),
+      do not warn the user.  Cache the descriptor if we're a cache; drop it
+      if we aren't.
 
   o Minor features (controller):
     - Warn the user when an application uses the obsolete binary v0

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2007-02-22 06:21:19 UTC (rev 9615)
+++ tor/trunk/src/or/directory.c	2007-02-22 07:41:10 UTC (rev 9616)
@@ -352,9 +352,9 @@
   /* No need to increment the failure count for routerdescs, since
    * it's not their fault. */
 
-  /* There's no need to call this here: we already call it every 10 seconds *
-   *  (DESCRIPTOR_RETRY_INTERVAL) in main.c -NM */
-  /* update_router_descriptor_downloads(time(NULL)); */
+  /* There's no relaunch descriptor downloads here: we already do it every 10
+   * seconds (DESCRIPTOR_RETRY_INTERVAL) in main.c */
+
   (void) conn;
 }
 
@@ -2057,9 +2057,8 @@
                 cp, (int)rs->n_download_failures);
   });
 
-  /* There's no need to call this here: we already call it every 10 seconds *
-   *  (DESCRIPTOR_RETRY_INTERVAL) in main.c -NM */
-  /* update_router_descriptor_downloads(time(NULL)); */
+  /* There's no relaunch descriptor downloads here: we already do it every 10
+   * seconds (DESCRIPTOR_RETRY_INTERVAL) in main.c */
 }
 
 /** Given a directory <b>resource</b> request, containing zero

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-02-22 06:21:19 UTC (rev 9615)
+++ tor/trunk/src/or/routerlist.c	2007-02-22 07:41:10 UTC (rev 9616)
@@ -729,8 +729,7 @@
   config_line_t *cl;
   or_options_t *options = get_options();
 
-  /* First, add any routers with similar network addresses.
-   * XXXX012 It's possible this will be really expensive; we'll see. */
+  /* First, add any routers with similar network addresses. */
   if (options->EnforceDistinctSubnets)
     routerlist_add_network_family(sl, router);
 
@@ -1909,19 +1908,19 @@
   } else if (from_fetch) {
     /* Only check the descriptor digest against the network statuses when
      * we are receiving in response to a fetch. */
-    /* XXXX012 This warning seems to happen fairly regularly when we download
-     * router information based on an old networkstatus, then discard the
-     * networkstatus between requesting the routers and getting the reply.
-     * That's no good at all.  I think we should switch to a behavior where we
-     * don't download a descriptor unless it's in a _recent_ networkstatus;
-     * also, we should drop this warning in (hopefully less likely) case where
-     * we decide we don't want a descriptor after we start downloading
-     * it. -NM */
+
     if (!signed_desc_digest_is_recognized(&router->cache_info)) {
-      log_warn(LD_DIR, "Dropping unrecognized descriptor for router '%s'",
+      /* We asked for it, so some networkstatus must have listed it when we
+       * did.  save it in case we're a cache and somebody else asks for it. */
+      log_info(LD_DIR,
+               "Received a no-longer-recognized descriptor for router '%s'",
                router->nickname);
       *msg = "Router descriptor is not referenced by any network-status.";
-      routerinfo_free(router);
+
+      /* Only journal this desc if we'll be serving it. */
+      if (!from_cache && get_options()->DirPort)
+        router_append_to_journal(&router->cache_info);
+      routerlist_insert_old(routerlist, router);
       return -1;
     }
   }
@@ -4029,7 +4028,12 @@
   n_download = 0;
   SMARTLIST_FOREACH(networkstatus_list, networkstatus_t *, ns,
     {
-      smartlist_t *dl = smartlist_create();
+      smartlist_t *dl;
+      if (ns->published_on + MAX_NETWORKSTATUS_AGE-10*60 > now) {
+        /* Don't download if the networkstatus is almost ancient. */
+        continue;
+      }
+      dl = smartlist_create();
       downloadable[ns_sl_idx] = dl;
       download_from[ns_sl_idx] = smartlist_create();
       SMARTLIST_FOREACH(ns->entries, routerstatus_t * , rs,



More information about the tor-commits mailing list