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

[or-cvs] r9799: Fix a comment and add a couple of assert to try to track dow (in tor/trunk: . src/or)



Author: nickm
Date: 2007-03-11 16:34:44 -0400 (Sun, 11 Mar 2007)
New Revision: 9799

Modified:
   tor/trunk/
   tor/trunk/src/or/routerlist.c
Log:
 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()



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r12535] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-03-11 16:37:53 UTC (rev 9798)
+++ tor/trunk/src/or/routerlist.c	2007-03-11 20:34:44 UTC (rev 9799)
@@ -1591,11 +1591,16 @@
 }
 
 /** 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 @@
 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 @@
     /* 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));