chiark
/
gitweb
/
~mdw
/
adns
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Also check specific query where applicable.
[adns]
/
src
/
query.c
diff --git
a/src/query.c
b/src/query.c
index b02abda87fc02e201bd4659a79a48c994f6253a0..172ff0607b150e81950276272fb9e22d8ca45671 100644
(file)
--- a/
src/query.c
+++ b/
src/query.c
@@
-27,7
+27,6
@@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
-#include <string.h>
#include <sys/time.h>
#include <sys/time.h>
@@
-42,7
+41,7
@@
static adns_query query_alloc(adns_state ads, const typeinfo *typei,
qu->answer= malloc(sizeof(*qu->answer)); if (!qu->answer) { free(qu); return 0; }
qu->ads= ads;
qu->answer= malloc(sizeof(*qu->answer)); if (!qu->answer) { free(qu); return 0; }
qu->ads= ads;
- qu->state= query_
udp
;
+ qu->state= query_
tosend
;
qu->back= qu->next= qu->parent= 0;
LIST_INIT(qu->children);
LINK_INIT(qu->siblings);
qu->back= qu->next= qu->parent= 0;
LIST_INIT(qu->children);
LINK_INIT(qu->siblings);
@@
-100,7
+99,7
@@
static void query_submit(adns_state ads, adns_query qu,
qu->query_dglen= qu->vb.used;
memcpy(qu->query_dgram,qu->vb.buf,qu->vb.used);
qu->query_dglen= qu->vb.used;
memcpy(qu->query_dgram,qu->vb.buf,qu->vb.used);
- adns__query_
udp
(qu,now);
+ adns__query_
send
(qu,now);
adns__autosys(ads,now);
}
adns__autosys(ads,now);
}
@@
-202,8
+201,10
@@
int adns_submit(adns_state ads,
adns_query qu;
const char *p;
adns_query qu;
const char *p;
+ adns__consistency(ads,0,cc_entex);
+
typei= adns__findtype(type);
typei= adns__findtype(type);
- if (!typei) return
adns_s_unknownrrtype
;
+ if (!typei) return
ENOSYS
;
r= gettimeofday(&now,0); if (r) goto x_errno;
qu= query_alloc(ads,typei,flags,now); if (!qu) goto x_errno;
r= gettimeofday(&now,0); if (r) goto x_errno;
qu= query_alloc(ads,typei,flags,now); if (!qu) goto x_errno;
@@
-237,15
+238,18
@@
int adns_submit(adns_state ads,
}
query_simple(ads,qu, owner,ol, typei,flags, now);
}
}
query_simple(ads,qu, owner,ol, typei,flags, now);
}
+ adns__consistency(ads,qu,cc_entex);
return 0;
x_adnsfail:
adns__query_fail(qu,stat);
return 0;
x_adnsfail:
adns__query_fail(qu,stat);
+ adns__consistency(ads,qu,cc_entex);
return 0;
x_errno:
r= errno;
assert(r);
return 0;
x_errno:
r= errno;
assert(r);
+ adns__consistency(ads,0,cc_entex);
return r;
}
return r;
}
@@
-362,15
+366,19
@@
static void free_query_allocs(adns_query qu) {
}
void adns_cancel(adns_query qu) {
}
void adns_cancel(adns_query qu) {
+ adns_state ads;
+
+ ads= qu->ads;
+ adns__consistency(ads,qu,cc_entex);
switch (qu->state) {
switch (qu->state) {
- case query_
udp
: case query_tcpwait: case query_tcpsent:
- LIST_UNLINK(
qu->
ads->timew,qu);
+ case query_
tosend
: case query_tcpwait: case query_tcpsent:
+ LIST_UNLINK(ads->timew,qu);
break;
case query_child:
break;
case query_child:
- LIST_UNLINK(
qu->
ads->childw,qu);
+ LIST_UNLINK(ads->childw,qu);
break;
case query_done:
break;
case query_done:
- LIST_UNLINK(
qu->
ads->output,qu);
+ LIST_UNLINK(ads->output,qu);
break;
default:
abort();
break;
default:
abort();
@@
-378,6
+386,7
@@
void adns_cancel(adns_query qu) {
free_query_allocs(qu);
free(qu->answer);
free(qu);
free_query_allocs(qu);
free(qu->answer);
free(qu);
+ adns__consistency(ads,0,cc_entex);
}
void adns__update_expires(adns_query qu, unsigned long ttl, struct timeval now) {
}
void adns__update_expires(adns_query qu, unsigned long ttl, struct timeval now) {
@@
-429,6
+438,8
@@
void adns__query_done(adns_query qu) {
adns_answer *ans;
adns_query parent;
adns_answer *ans;
adns_query parent;
+ cancel_children(qu);
+
qu->id= -1;
ans= qu->answer;
qu->id= -1;
ans= qu->answer;
@@
-455,7
+466,7
@@
void adns__query_done(adns_query qu) {
parent= qu->parent;
if (parent) {
LIST_UNLINK_PART(parent->children,qu,siblings.);
parent= qu->parent;
if (parent) {
LIST_UNLINK_PART(parent->children,qu,siblings.);
-
if (!parent->children.head)
LIST_UNLINK(qu->ads->childw,parent);
+ LIST_UNLINK(qu->ads->childw,parent);
qu->ctx.callback(parent,qu);
free_query_allocs(qu);
free(qu);
qu->ctx.callback(parent,qu);
free_query_allocs(qu);
free(qu);
@@
-463,6
+474,7
@@
void adns__query_done(adns_query qu) {
makefinal_query(qu);
LIST_LINK_TAIL(qu->ads->output,qu);
}
makefinal_query(qu);
LIST_LINK_TAIL(qu->ads->output,qu);
}
+ qu->state= query_done;
}
void adns__query_fail(adns_query qu, adns_status stat) {
}
void adns__query_fail(adns_query qu, adns_status stat) {