From 98c3403ce738fe2c29d760938506f86e7274a0dd Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 11 Mar 2007 20:34:44 +0000 Subject: [PATCH] r12535@Kushana: nickm | 2007-03-11 16:34:40 -0400 Fix a comment and add a couple of assert to try to track down another assert in routerlist_assert_ok() svn:r9799 --- src/or/routerlist.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/or/routerlist.c b/src/or/routerlist.c index f9f9b53677..d81f3e4c14 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1591,11 +1591,16 @@ _routerlist_find_elt(smartlist_t *sl, void *ri, int idx) } /** Insert an item ri into the routerlist rl, updating indices - * as needed. */ + * as needed. There must be no previous member of rl with the same + * identity giest as ri: If there is, call routerlist_replace + * instead. + */ static void routerlist_insert(routerlist_t *rl, routerinfo_t *ri) { - digestmap_set(rl->identity_map, ri->cache_info.identity_digest, ri); + routerinfo_t *ri_old; + ri_old = digestmap_set(rl->identity_map, ri->cache_info.identity_digest, ri); + tor_assert(!ri_old); digestmap_set(rl->desc_digest_map, ri->cache_info.signed_descriptor_digest, &(ri->cache_info)); smartlist_add(rl->routers, ri); @@ -1684,6 +1689,7 @@ static void routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old, routerinfo_t *ri_new, int idx, int make_old) { + routerinfo_t *ri_tmp; tor_assert(ri_old != ri_new); idx = _routerlist_find_elt(rl->routers, ri_old, idx); router_dir_info_changed(); @@ -1701,7 +1707,9 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old, /* digests don't match; digestmap_set won't replace */ digestmap_remove(rl->identity_map, ri_old->cache_info.identity_digest); } - digestmap_set(rl->identity_map, ri_new->cache_info.identity_digest, ri_new); + ri_tmp = digestmap_set(rl->identity_map, + ri_new->cache_info.identity_digest, ri_new); + tor_assert(!ri_tmp); digestmap_set(rl->desc_digest_map, ri_new->cache_info.signed_descriptor_digest, &(ri_new->cache_info));