[or-cvs] r10869: Change routerlist_remove to not take an index argument we do (tor/trunk/src/or)

weasel at seul.org weasel at seul.org
Wed Jul 18 14:02:48 UTC 2007


Author: weasel
Date: 2007-07-18 10:02:47 -0400 (Wed, 18 Jul 2007)
New Revision: 10869

Modified:
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/routerlist.c
Log:
Change routerlist_remove to not take an index argument we do not need anyway.
Now the only remaining caller of _routerlist_find_elt is an assert()

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2007-07-18 10:53:43 UTC (rev 10868)
+++ tor/trunk/src/or/dirserv.c	2007-07-18 14:02:47 UTC (rev 10869)
@@ -693,7 +693,8 @@
     if (r & FP_REJECT) {
       log_info(LD_DIRSERV, "Router '%s' is now rejected: %s",
                ent->nickname, msg?msg:"");
-      routerlist_remove(rl, ent, i--, 0);
+      routerlist_remove(rl, ent, 0);
+      i--;
       changed = 1;
       continue;
     }

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-07-18 10:53:43 UTC (rev 10868)
+++ tor/trunk/src/or/or.h	2007-07-18 14:02:47 UTC (rev 10869)
@@ -3303,8 +3303,7 @@
 void routerlist_reset_warnings(void);
 void routerlist_free(routerlist_t *routerlist);
 void dump_routerlist_mem_usage(int severity);
-void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int idx,
-                       int make_old);
+void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old);
 void routerinfo_free(routerinfo_t *router);
 void extrainfo_free(extrainfo_t *extrainfo);
 

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-07-18 10:53:43 UTC (rev 10868)
+++ tor/trunk/src/or/routerlist.c	2007-07-18 14:02:47 UTC (rev 10869)
@@ -2021,14 +2021,15 @@
  * If <b>make_old</b> is true, instead of deleting the router, we try adding
  * it to rl-&gt;old_routers. */
 void
-routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int idx, int make_old)
+routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old)
 {
   routerinfo_t *ri_tmp;
   extrainfo_t *ei_tmp;
+  int idx = ri->routerlist_index;
+  tor_assert(0 <= idx && idx < smartlist_len(rl->routers));
+  tor_assert(smartlist_get(rl->routers, idx) == ri);
+
   routerlist_check_bug_417();
-  idx = _routerlist_find_elt(rl->routers, ri, idx);
-  if (idx < 0)
-    return;
   ri->routerlist_index = -1;
   smartlist_del(rl->routers, idx);
   if (idx < smartlist_len(rl->routers)) {
@@ -2080,9 +2081,9 @@
   signed_descriptor_t *sd_tmp;
   extrainfo_t *ei_tmp;
   routerlist_check_bug_417();
-  idx = _routerlist_find_elt(rl->old_routers, sd, idx);
-  if (idx < 0)
-    return;
+  tor_assert(0 <= idx && idx < smartlist_len(rl->old_routers));
+  tor_assert(smartlist_get(rl->old_routers, idx) == sd);
+
   smartlist_del(rl->old_routers, idx);
   sd_tmp = sdmap_remove(rl->desc_digest_map,
                         sd->signed_descriptor_digest);
@@ -2692,7 +2693,8 @@
         log_info(LD_DIR,
                  "Forgetting obsolete (too old) routerinfo for router '%s'",
                  router->nickname);
-        routerlist_remove(routerlist, router, i--, 1);
+        routerlist_remove(routerlist, router, 1);
+        i--;
       }
     }
   }



More information about the tor-commits mailing list