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

[or-cvs] Fix bugs in routerlist_remove_old_cached_routers_with_id()



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

Modified Files:
	routerlist.c 
Log Message:
Fix bugs in routerlist_remove_old_cached_routers_with_id()

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.360
retrieving revision 1.361
diff -u -d -r1.360 -r1.361
--- routerlist.c	1 Nov 2005 17:34:17 -0000	1.360
+++ routerlist.c	4 Nov 2005 16:47:26 -0000	1.361
@@ -1184,7 +1184,7 @@
                             ri->signed_descriptor_digest);
   tor_assert(ri_tmp == ri);
   routerinfo_free(ri);
-  // routerlist_assert_ok(rl);
+  routerlist_assert_ok(rl);
 }
 
 /** Remove <b>ri_old</b> from the routerlist <b>rl</b>, and replace it with
@@ -1559,18 +1559,18 @@
   for (i = lo; i <= hi; ++i) {
     routerinfo_t *r = smartlist_get(lst, i);
     routerinfo_t *r_next;
-    lifespans[i].idx = i;
+    lifespans[i-lo].idx = i;
     if (i < hi) {
       r_next = smartlist_get(lst, i+1);
       tor_assert(r->published_on <= r_next->published_on);
-      lifespans[i].duration = r_next->published_on - r->published_on;
+      lifespans[i-lo].duration = r_next->published_on - r->published_on;
     } else {
       r_next = NULL;
-      lifespans[i].duration = INT_MAX;
+      lifespans[i-lo].duration = INT_MAX;
     }
     if (r->published_on < cutoff && n_rmv < n_extra) {
       ++n_rmv;
-      lifespans[i].old = 1;
+      lifespans[i-lo].old = 1;
       rmv[i-lo] = 1;
     }
   }
@@ -1590,7 +1590,7 @@
     }
   }
 
-  for (i = hi; i >= lo; ++i) {
+  for (i = hi; i >= lo; --i) {
     if (rmv[i-lo])
       routerlist_remove_old(routerlist, smartlist_get(lst, i), i);
   }