chiark / gitweb /
Reentrancy: adns__internal_submit does list handling
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Oct 2014 20:10:23 +0000 (21:10 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Oct 2014 20:09:56 +0000 (21:09 +0100)
Move the formulaic queue management from the call sites to
adns__internal_submit.  The requirement to do this wasn't mentioned in
adns__internal_submit's comment, and now that it's not there it
probably isn't worth remarking on.

No ultimate functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/internal.h
src/query.c
src/types.c

index 5e34956..4fd6ee8 100644 (file)
@@ -601,6 +601,7 @@ void adns__query_send(adns_query qu, struct timeval now);
 /* From query.c: */
 
 adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
+                                 adns_query parent,
                                  const typeinfo *typei, adns_rrtype type,
                                  vbuf *qumsg_vb, int id,
                                  adns_queryflags flags, struct timeval now,
index a5882f3..6a1ec75 100644 (file)
@@ -148,6 +148,7 @@ static adns_status check_domain_name(adns_state ads, adns_queryflags flags,
 }
 
 adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
+                                 adns_query parent,
                                  const typeinfo *typei, adns_rrtype type,
                                  vbuf *qumsg_vb, int id,
                                  adns_queryflags flags, struct timeval now,
@@ -161,6 +162,8 @@ adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
   if (!qu) { err = adns_s_nomemory; goto x_err; }
   *query_r= qu;
 
+  qu->parent= parent;
+  LIST_LINK_TAIL_PART(parent->children,qu,siblings.);
   memcpy(&qu->ctx,ctx,sizeof(qu->ctx));
   query_submit(ads,qu, typei,qumsg_vb,id,flags,now);
   
index eacf2f3..cb343be 100644 (file)
@@ -588,15 +588,13 @@ static adns_status pap_hostaddr(const parseinfo *pai, int *cbyte_io,
   nflags= adns_qf_quoteok_query;
   if (!(pai->qu->flags & adns_qf_cname_loose)) nflags |= adns_qf_cname_forbid;
   
-  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_addr),
+  st= adns__internal_submit(pai->ads, &nqu, pai->qu,
+                           adns__findtype(adns_r_addr),
                            ((adns_r_addr & adns_rrt_reprmask) |
                             (pai->qu->answer->type & ~adns_rrt_reprmask)),
                            &pai->qu->vb, id, nflags, pai->now, &ctx);
   if (st) return st;
 
-  nqu->parent= pai->qu;
-  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
-
   return adns_s_ok;
 }
 
@@ -849,13 +847,12 @@ static adns_status pa_ptr(const parseinfo *pai, int dmstart,
   ctx.callback= icb_ptr;
   memset(&ctx.pinfo,0,sizeof(ctx.pinfo));
   memset(&ctx.tinfo,0,sizeof(ctx.tinfo));
-  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(rrtype),
+  st= adns__internal_submit(pai->ads, &nqu, pai->qu,
+                           adns__findtype(rrtype),
                            rrtype, &pai->qu->vb, id,
                            adns_qf_quoteok_query, pai->now, &ctx);
   if (st) return st;
 
-  nqu->parent= pai->qu;
-  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
   return adns_s_ok;
 }