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

[or-cvs] r12413: Re-set all of the indices immediately after sorting old_rout (in tor/trunk: . src/or)



Author: nickm
Date: 2007-11-07 12:29:16 -0500 (Wed, 07 Nov 2007)
New Revision: 12413

Modified:
   tor/trunk/
   tor/trunk/src/or/routerlist.c
Log:
 r16527@catbus:  nickm | 2007-11-07 12:27:59 -0500
 Re-set all of the indices immediately after sorting old_routers.  Fixes a crash.



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

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-11-07 17:11:23 UTC (rev 12412)
+++ tor/trunk/src/or/routerlist.c	2007-11-07 17:29:16 UTC (rev 12413)
@@ -2987,12 +2987,16 @@
     goto done;
 
   smartlist_sort(routerlist->old_routers, _compare_old_routers_by_identity);
+  /* Fix indices. */
+  for (i = 0; i < smartlist_len(routerlist_old_routers); ++i) {
+    signed_descriptor_t *r = smartlist_get(routerlist->old_routers, i);
+    r->routerlist_index = i;
+  }
 
   /* Iterate through the list from back to front, so when we remove descriptors
    * we don't mess up groups we haven't gotten to. */
   for (i = smartlist_len(routerlist->old_routers)-1; i >= 0; --i) {
     signed_descriptor_t *r = smartlist_get(routerlist->old_routers, i);
-    r->routerlist_index = i;
     if (!cur_id) {
       cur_id = r->identity_digest;
       hi = i;