summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-03-11 20:34:44 +0000
committerNick Mathewson <nickm@torproject.org>2007-03-11 20:34:44 +0000
commit98c3403ce738fe2c29d760938506f86e7274a0dd (patch)
tree3a02e32012dc50c06d9b70b2c2eda03127694ba7
parentf25e2167f556ae8ba456d935c6bf02603af4f2da (diff)
downloadtor-98c3403ce738fe2c29d760938506f86e7274a0dd.tar.gz
tor-98c3403ce738fe2c29d760938506f86e7274a0dd.zip
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
-rw-r--r--src/or/routerlist.c14
1 files 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 <b>ri</b> into the routerlist <b>rl</b>, updating indices
- * as needed. */
+ * as needed. There must be no previous member of <b>rl</b> with the same
+ * identity giest as <b>ri</b>: 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));