mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
r6981@Kushana: nickm | 2006-07-31 13:23:26 -0400
More asserts for cache correctness. svn:r6960
This commit is contained in:
parent
ea0f5ec8ad
commit
58c0ac77be
13
src/or/dns.c
13
src/or/dns.c
@ -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)
|
|||||||
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)
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user