[or-cvs] Fix an annoying rep violation bug
Nick Mathewson
nickm at seul.org
Thu Oct 27 23:06:11 UTC 2005
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv23210
Modified Files:
routerlist.c
Log Message:
Fix an annoying rep violation bug
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.354
retrieving revision 1.355
diff -u -d -r1.354 -r1.355
--- routerlist.c 27 Oct 2005 00:34:39 -0000 1.354
+++ routerlist.c 27 Oct 2005 23:06:09 -0000 1.355
@@ -1122,7 +1122,7 @@
break;
});
}
- return -1;
+ return idx;
}
/** Insert an item <b>ri</b> into the routerlist <b>rl</b>, updating indices
@@ -1142,10 +1142,10 @@
if (get_options()->DirPort) {
digestmap_set(rl->desc_digest_map, ri->signed_descriptor_digest, ri);
smartlist_add(rl->old_routers, ri);
- // routerlist_assert_ok(rl);
} else {
routerinfo_free(ri);
}
+ // routerlist_assert_ok(rl);
}
/** Remove an item <b>ri</b> into the routerlist <b>rl</b>, updating indices
@@ -1170,8 +1170,8 @@
ri->signed_descriptor_digest);
tor_assert(ri_tmp == ri);
routerinfo_free(ri);
- // routerlist_assert_ok(rl);
}
+ // routerlist_assert_ok(rl);
}
void
@@ -1198,11 +1198,14 @@
routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
routerinfo_t *ri_new, int idx, int make_old)
{
+ tor_assert(ri_old != ri_new);
idx = _routerlist_find_elt(rl->routers, ri_old, idx);
if (idx >= 0) {
smartlist_set(rl->routers, idx, ri_new);
} else {
- smartlist_add(rl->routers, ri_new);
+ warn(LD_BUG, "Appending entry from routerlist_replace.");
+ routerlist_insert(rl, ri_new);
+ return;
}
if (memcmp(ri_old->identity_digest, ri_new->identity_digest, DIGEST_LEN)) {
/* digests don't match; digestmap_set won't replace */
@@ -1214,13 +1217,15 @@
if (make_old && get_options()->DirPort) {
smartlist_add(rl->old_routers, ri_old);
} else {
- if (memcmp(ri_old->signed_descriptor_digest, ri_new->signed_descriptor_digest,
+ if (memcmp(ri_old->signed_descriptor_digest,
+ ri_new->signed_descriptor_digest,
DIGEST_LEN)) {
/* digests don't match; digestmap_set didn't replace */
digestmap_remove(rl->desc_digest_map, ri_old->signed_descriptor_digest);
}
routerinfo_free(ri_old);
}
+ // routerlist_assert_ok(rl);
}
/** Free all memory held by the rouerlist module */
More information about the tor-commits
mailing list