* - consistency checks
*/
/*
- * This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
+ * This file is
+ * Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
+ *
+ * It is part of adns, which is
+ * Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
+ * Copyright (C) 1999 Tony Finch <dot@dotat.at>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "internal.h"
-void adns_checkconsistency(adns_state ads) { adns__consistency(ads,cc_user); }
+void adns_checkconsistency(adns_state ads, adns_query qu) {
+ adns__consistency(ads,qu,cc_user);
+}
#define DLIST_CHECK(list, nodevar, part, body) \
if ((list).head) { \
} \
}
+#define DLIST_ASSERTON(node, nodevar, list, part) \
+ do { \
+ for ((nodevar)= (list).head; \
+ (nodevar) != (node); \
+ (nodevar)= (nodevar)->part next) { \
+ assert((nodevar)); \
+ } \
+ } while(0)
+
static void checkc_query_alloc(adns_state ads, adns_query qu) {
allocnode *an;
}
static void checkc_query(adns_state ads, adns_query qu) {
+ adns_query child;
+
assert(qu->udpnextserver < ads->nservers);
assert(!(qu->udpsent & (~0UL << ads->nservers)));
assert(!(qu->tcpfailed & (~0UL << ads->nservers)));
assert(qu->udpretries <= UDPMAXRETRIES);
assert(qu->search_pos <= ads->nsearchlist);
+ if (qu->parent) DLIST_ASSERTON(qu, child, qu->parent->children, siblings.);
}
static void checkc_global(adns_state ads) {
assert(qu->state == query_done);
assert(!qu->children.head && !qu->children.tail);
assert(!qu->parent);
+ assert(!qu->allocations.head && !qu->allocations.tail);
checkc_query(ads,qu);
});
}
-void adns__consistency(adns_state ads, consistency_checks cc) {
+void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc) {
+ adns_query search;
+
switch (cc) {
case cc_user:
break;
checkc_queue_timew(ads);
checkc_queue_childw(ads);
checkc_queue_output(ads);
+
+ if (qu) {
+ switch (qu->state) {
+ case query_tosend:
+ case query_tcpwait:
+ case query_tcpsent:
+ DLIST_ASSERTON(qu, search, ads->timew, );
+ break;
+ case query_child:
+ DLIST_ASSERTON(qu, search, ads->childw, );
+ break;
+ case query_done:
+ DLIST_ASSERTON(qu, search, ads->output, );
+ break;
+ default:
+ assert(!"specific query state");
+ }
+ }
}