Browse Source

Fix bugs in routerlist_remove_old_cached_routers_with_id()

svn:r5348
Nick Mathewson 20 years ago
parent
commit
757def59b6
1 changed files with 6 additions and 6 deletions
  1. 6 6
      src/or/routerlist.c

+ 6 - 6
src/or/routerlist.c

@@ -1184,7 +1184,7 @@ routerlist_remove_old(routerlist_t *rl, routerinfo_t *ri, int idx)
                             ri->signed_descriptor_digest);
                             ri->signed_descriptor_digest);
   tor_assert(ri_tmp == ri);
   tor_assert(ri_tmp == ri);
   routerinfo_free(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
 /** Remove <b>ri_old</b> from the routerlist <b>rl</b>, and replace it with
@@ -1559,18 +1559,18 @@ routerlist_remove_old_cached_routers_with_id(time_t cutoff, int lo, int hi)
   for (i = lo; i <= hi; ++i) {
   for (i = lo; i <= hi; ++i) {
     routerinfo_t *r = smartlist_get(lst, i);
     routerinfo_t *r = smartlist_get(lst, i);
     routerinfo_t *r_next;
     routerinfo_t *r_next;
-    lifespans[i].idx = i;
+    lifespans[i-lo].idx = i;
     if (i < hi) {
     if (i < hi) {
       r_next = smartlist_get(lst, i+1);
       r_next = smartlist_get(lst, i+1);
       tor_assert(r->published_on <= r_next->published_on);
       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 {
     } else {
       r_next = NULL;
       r_next = NULL;
-      lifespans[i].duration = INT_MAX;
+      lifespans[i-lo].duration = INT_MAX;
     }
     }
     if (r->published_on < cutoff && n_rmv < n_extra) {
     if (r->published_on < cutoff && n_rmv < n_extra) {
       ++n_rmv;
       ++n_rmv;
-      lifespans[i].old = 1;
+      lifespans[i-lo].old = 1;
       rmv[i-lo] = 1;
       rmv[i-lo] = 1;
     }
     }
   }
   }
@@ -1590,7 +1590,7 @@ routerlist_remove_old_cached_routers_with_id(time_t cutoff, int lo, int hi)
     }
     }
   }
   }
 
 
-  for (i = hi; i >= lo; ++i) {
+  for (i = hi; i >= lo; --i) {
     if (rmv[i-lo])
     if (rmv[i-lo])
       routerlist_remove_old(routerlist, smartlist_get(lst, i), i);
       routerlist_remove_old(routerlist, smartlist_get(lst, i), i);
   }
   }