[or-cvs] r9381: resolve an XXX, add a new XXX, simplify some code (tor/trunk/src/or)

arma at seul.org arma at seul.org
Mon Jan 22 06:00:03 UTC 2007


Author: arma
Date: 2007-01-22 00:59:59 -0500 (Mon, 22 Jan 2007)
New Revision: 9381

Modified:
   tor/trunk/src/or/routerlist.c
Log:
resolve an XXX, add a new XXX, simplify some code


Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-01-22 02:34:50 UTC (rev 9380)
+++ tor/trunk/src/or/routerlist.c	2007-01-22 05:59:59 UTC (rev 9381)
@@ -508,8 +508,8 @@
 
 /** Pick a random running valid directory server/mirror from our
  * routerlist.  Don't pick an authority if any non-authorities are viable.
- * If <b>fascistfirewall</b>,
- * make sure the router we pick is allowed by our firewall options.
+ * If <b>fascistfirewall</b>, make sure the router we pick is allowed
+ * by our firewall options.
  * If <b>requireother</b>, it cannot be us. If <b>for_v2_directory</b>,
  * choose a directory server new enough to support the v2 directory
  * functionality.
@@ -836,8 +836,8 @@
   return v;
 }
 
-/** Add every router from our routerlist that is currently running to
- * <b>sl</b>, so that we can pick a node for a circuit.
+/** Add every suitable router from our routerlist to <b>sl</b>, so that
+ * we can pick a node for a circuit.
  */
 static void
 router_add_running_routers_to_smartlist(smartlist_t *sl, int allow_invalid,
@@ -851,14 +851,11 @@
   {
     if (router->is_running &&
         router->purpose == ROUTER_PURPOSE_GENERAL &&
-        (router->is_valid ||
-/* XXX this next part is wrong and should be fixed one day -RD */
-        (allow_invalid &&
-         !router_is_unreliable(router, need_uptime,
-                               need_capacity, need_guard)))) {
-      /* If it's running, and either it's valid or we're ok picking
-       * invalid routers and this one is suitable.
-       */
+        (router->is_valid || allow_invalid) &&
+        !router_is_unreliable(router, need_uptime,
+                              need_capacity, need_guard)) {
+      /* If it's running, and it's suitable according to the
+       * other flags we had in mind */
       smartlist_add(sl, router);
     }
   });
@@ -923,26 +920,6 @@
   return 0;
 }
 
-/** Remove from routerlist <b>sl</b> all routers that are not
- * sufficiently stable. */
-static void
-routerlist_sl_remove_unreliable_routers(smartlist_t *sl, int need_uptime,
-                                        int need_capacity, int need_guard)
-{
-  int i;
-  routerinfo_t *router;
-
-  for (i = 0; i < smartlist_len(sl); ++i) {
-    router = smartlist_get(sl, i);
-    if (router_is_unreliable(router, need_uptime,
-                             need_capacity, need_guard)) {
-//      log(LOG_DEBUG, "Router '%s' has insufficient uptime; deleting.",
- //         router->nickname);
-      smartlist_del(sl, i--);
-    }
-  }
-}
-
 /** Return the smaller of the router's configured BandwidthRate
  * and its advertised capacity. */
 uint32_t
@@ -969,7 +946,7 @@
   uint64_t rand_bw, tmp;
   double exit_weight;
 
-  /* First count the total bandwidth weight, and make a smartlist
+  /* First count the total bandwidth weight, and make a list
    * of each value. */
   bandwidths = tor_malloc(sizeof(uint32_t)*smartlist_len(sl));
   for (i = 0; i < smartlist_len(sl); ++i) {
@@ -1036,6 +1013,8 @@
  * a minimum uptime, return one of those.
  * If <b>need_capacity</b> is non-zero, weight your choice by the
  * advertised capacity of each router.
+ *
+ * DOCDOC allow_invalid, need_guard, weight_for_exit
  */
 routerinfo_t *
 router_choose_random_node(const char *preferred,
@@ -1073,12 +1052,12 @@
     smartlist_subtract(sl,excludednodes);
     if (excludedsmartlist)
       smartlist_subtract(sl,excludedsmartlist);
-    routerlist_sl_remove_unreliable_routers(sl, need_uptime,
-                                            need_capacity, need_guard);
+
     if (need_capacity)
       choice = routerlist_sl_choose_by_bandwidth(sl, weight_for_exit);
     else
       choice = smartlist_choose(sl);
+
     smartlist_free(sl);
     if (!choice && (need_uptime || need_capacity || need_guard)) {
       /* try once more -- recurse but with fewer restrictions. */
@@ -3780,6 +3759,7 @@
       smartlist_len(networkstatus_list) <= get_n_v2_authorities()/2) {
     log_info(LD_DIR,
              "Not enough networkstatus documents to launch requests.");
+    /* XXX012 should we return here or something? */
   }
 
   downloadable = router_list_client_downloadable();
@@ -3832,7 +3812,7 @@
 
 /** Launch downloads for router status as needed, using the strategy used by
  * authorities and caches: download every descriptor we don't have but would
- * serve from a random authoritiy that lists it. */
+ * serve, from a random authority that lists it. */
 static void
 update_router_descriptor_cache_downloads(time_t now)
 {



More information about the tor-commits mailing list