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

[or-cvs] r10720: Three more assertions which hopefully are sane, Nick? They m (tor/trunk/src/or)



Author: weasel
Date: 2007-07-02 11:13:52 -0400 (Mon, 02 Jul 2007)
New Revision: 10720

Modified:
   tor/trunk/src/or/routerlist.c
Log:
Three more assertions which hopefully are sane, Nick?  They might help track down #417.

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-07-01 20:25:42 UTC (rev 10719)
+++ tor/trunk/src/or/routerlist.c	2007-07-02 15:13:52 UTC (rev 10720)
@@ -1867,6 +1867,7 @@
 static INLINE int
 _routerlist_find_elt(smartlist_t *sl, void *ri, int idx)
 {
+  tor_assert(idx < sl->num_used);
   if (idx < 0 || smartlist_get(sl, idx) != ri) {
     idx = -1;
     SMARTLIST_FOREACH(sl, routerinfo_t *, r,
@@ -2125,6 +2126,7 @@
     smartlist_set(rl->routers, idx, ri_new);
     ri_old->routerlist_index = -1;
     ri_new->routerlist_index = idx;
+    tor_assert( _routerlist_find_elt(rl->routers, ri_old, 0) == -1 );
   } else {
     log_warn(LD_BUG, "Appending entry from routerlist_replace.");
     routerlist_insert(rl, ri_new);
@@ -2420,6 +2422,7 @@
                          router->cache_info.identity_digest);
   if (old_router) {
     int pos = old_router->routerlist_index;
+    tor_assert(0 <= pos && pos < routerlist->routers->num_used);
     tor_assert(smartlist_get(routerlist->routers, pos) == old_router);
 
     if (router->cache_info.published_on <=