Commit 58c0ac77 authored by Nick Mathewson's avatar Nick Mathewson 🎨
Browse files

r6981@Kushana: nickm | 2006-07-31 13:23:26 -0400

 More asserts for cache correctness.


svn:r6960
parent ea0f5ec8
...@@ -226,6 +226,8 @@ static void ...@@ -226,6 +226,8 @@ static void
set_expiry(cached_resolve_t *resolve, time_t expires) set_expiry(cached_resolve_t *resolve, time_t expires)
{ {
tor_assert(resolve && resolve->expire == 0); tor_assert(resolve && resolve->expire == 0);
if (!cached_resolve_pqueue)
cached_resolve_pqueue = smartlist_create();
resolve->expire = expires; resolve->expire = expires;
smartlist_pqueue_add(cached_resolve_pqueue, smartlist_pqueue_add(cached_resolve_pqueue,
_compare_cached_resolves_by_expiry, _compare_cached_resolves_by_expiry,
...@@ -1241,9 +1243,15 @@ assert_resolve_ok(cached_resolve_t *resolve) ...@@ -1241,9 +1243,15 @@ assert_resolve_ok(cached_resolve_t *resolve)
tor_assert(resolve); tor_assert(resolve);
tor_assert(resolve->magic == CACHED_RESOLVE_MAGIC); tor_assert(resolve->magic == CACHED_RESOLVE_MAGIC);
tor_assert(strlen(resolve->address) < MAX_ADDRESSLEN); tor_assert(strlen(resolve->address) < MAX_ADDRESSLEN);
tor_assert(tor_strisnonupper(resolve->address));
if (resolve->state != CACHE_STATE_PENDING) { if (resolve->state != CACHE_STATE_PENDING) {
tor_assert(!resolve->pending_connections); tor_assert(!resolve->pending_connections);
} }
if (resolve->state == CACHE_STATE_PENDING ||
resolve->state == CACHE_STATE_DONE) {
tor_assert(!resolve->ttl);
tor_assert(!resolve->addr);
}
} }
static void static void
...@@ -1260,5 +1268,10 @@ assert_cache_ok(void) ...@@ -1260,5 +1268,10 @@ assert_cache_ok(void)
assert_resolve_ok(*resolve); assert_resolve_ok(*resolve);
tor_assert((*resolve)->state != CACHE_STATE_DONE); tor_assert((*resolve)->state != CACHE_STATE_DONE);
} }
if (!cached_resolve_pqueue)
return;
smartlist_pqueue_assert_ok(cached_resolve_pqueue,
_compare_cached_resolves_by_expiry);
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment