X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=adns.git;a=blobdiff_plain;f=src%2Fquery.c;h=d09702e3702f555d8fc1c85b1c8a129d911ce55a;hp=3c98040ace1ef57d02910a18259db0f6f5a90dc8;hb=2dee2b7a71c858a78d06814eb98f23ede5602e37;hpb=a889f4bef2235d4358c39113a745551773f2450b diff --git a/src/query.c b/src/query.c index 3c98040..d09702e 100644 --- a/src/query.c +++ b/src/query.c @@ -5,12 +5,11 @@ * - query submission and cancellation (user-visible and internal) */ /* - * This file is - * Copyright (C) 1997-2000 Ian Jackson - * - * It is part of adns, which is - * Copyright (C) 1997-2000 Ian Jackson - * Copyright (C) 1999-2000 Tony Finch + * This file is part of adns, which is + * Copyright (C) 1997-2000,2003,2006 Ian Jackson + * Copyright (C) 1999-2000,2003,2006 Tony Finch + * Copyright (C) 1991 Massachusetts Institute of Technology + * (See the file INSTALL for full details.) * * 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 @@ -37,7 +36,8 @@ #include "internal.h" -static adns_query query_alloc(adns_state ads, const typeinfo *typei, +static adns_query query_alloc(adns_state ads, + const typeinfo *typei, adns_rrtype type, adns_queryflags flags, struct timeval now) { /* Allocate a virgin query and return it. */ adns_query qu; @@ -79,7 +79,7 @@ static adns_query query_alloc(adns_state ads, const typeinfo *typei, qu->answer->status= adns_s_ok; qu->answer->cname= qu->answer->owner= 0; - qu->answer->type= typei->type; + qu->answer->type= type; qu->answer->expires= -1; qu->answer->nrrs= 0; qu->answer->rrs.untyped= 0; @@ -115,7 +115,7 @@ adns_status adns__internal_submit(adns_state ads, adns_query *query_r, const qcontext *ctx) { adns_query qu; - qu= query_alloc(ads,typei,flags,now); + qu= query_alloc(ads,typei,typei->typekey,flags,now); if (!qu) { adns__vbuf_free(qumsg_vb); return adns_s_nomemory; } *query_r= qu; @@ -133,7 +133,8 @@ static void query_simple(adns_state ads, adns_query qu, int id; adns_status stat; - stat= adns__mkquery(ads,&qu->vb,&id, owner,ol, typei,flags); + stat= adns__mkquery(ads,&qu->vb,&id, owner,ol, + typei,qu->answer->type, flags); if (stat) { if (stat == adns_s_querydomaintoolong && (flags & adns_qf_search)) { adns__search_next(ads,qu,now); @@ -225,7 +226,7 @@ int adns_submit(adns_state ads, 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; + qu= query_alloc(ads,typei,type,flags,now); if (!qu) goto x_errno; qu->ctx.ext= context; qu->ctx.callback= 0; @@ -537,6 +538,9 @@ void adns__query_done(adns_query qu) { qu->typei->diff_needswap, qu->ads); } + if (ans->nrrs && qu->typei->postsort) { + qu->typei->postsort(qu->ads, ans->rrs.bytes, ans->nrrs, qu->typei); + } ans->expires= qu->expires; parent= qu->parent;