chiark / gitweb /
Copyrights now acknowledge fanf for adns. Individual file copyrights too.
[adns.git] / src / query.c
index d1d0b31b997e52ecd9e719be2ea62e22d28e4e86..53eecd9b902e47ff11c30700da4a8dcbfbfc4032 100644 (file)
@@ -5,7 +5,12 @@
  * - query submission and cancellation (user-visible and internal)
  */
 /*
- *  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
@@ -201,7 +206,7 @@ int adns_submit(adns_state ads,
   adns_query qu;
   const char *p;
 
-  adns__consistency(ads,cc_entex);
+  adns__consistency(ads,0,cc_entex);
 
   typei= adns__findtype(type);
   if (!typei) return ENOSYS;
@@ -238,18 +243,18 @@ int adns_submit(adns_state ads,
     }
     query_simple(ads,qu, owner,ol, typei,flags, now);
   }
-  adns__consistency(ads,cc_entex);
+  adns__consistency(ads,qu,cc_entex);
   return 0;
 
  x_adnsfail:
   adns__query_fail(qu,stat);
-  adns__consistency(ads,cc_entex);
+  adns__consistency(ads,qu,cc_entex);
   return 0;
 
  x_errno:
   r= errno;
   assert(r);
-  adns__consistency(ads,cc_entex);
+  adns__consistency(ads,0,cc_entex);
   return r;
 }
 
@@ -346,7 +351,6 @@ static void cancel_children(adns_query qu) {
     ncqu= cqu->siblings.next;
     adns_cancel(cqu);
   }
-  LIST_INIT(qu->children);
 }
 
 void adns__reset_preserved(adns_query qu) {
@@ -362,6 +366,7 @@ static void free_query_allocs(adns_query qu) {
 
   cancel_children(qu);
   for (an= qu->allocations.head; an; an= ann) { ann= an->next; free(an); }
+  LIST_INIT(qu->allocations);
   adns__vbuf_free(&qu->vb);
 }
 
@@ -369,7 +374,8 @@ void adns_cancel(adns_query qu) {
   adns_state ads;
 
   ads= qu->ads;
-  adns__consistency(ads,cc_entex);
+  adns__consistency(ads,qu,cc_entex);
+  if (qu->parent) LIST_UNLINK_PART(qu->parent->children,qu,siblings.);
   switch (qu->state) {
   case query_tosend: case query_tcpwait: case query_tcpsent:
     LIST_UNLINK(ads->timew,qu);
@@ -386,7 +392,7 @@ void adns_cancel(adns_query qu) {
   free_query_allocs(qu);
   free(qu->answer);
   free(qu);
-  adns__consistency(ads,cc_entex);
+  adns__consistency(ads,0,cc_entex);
 }
 
 void adns__update_expires(adns_query qu, unsigned long ttl, struct timeval now) {
@@ -473,8 +479,8 @@ void adns__query_done(adns_query qu) {
   } else {
     makefinal_query(qu);
     LIST_LINK_TAIL(qu->ads->output,qu);
+    qu->state= query_done;
   }
-  qu->state= query_done;
 }
 
 void adns__query_fail(adns_query qu, adns_status stat) {