Lines Matching refs:iq

75 static void target_count_increase_nx(struct iter_qstate* iq, int num);
134 struct iter_qstate* iq = (struct iter_qstate*)regional_alloc(
136 qstate->minfo[id] = iq;
137 if(!iq)
139 memset(iq, 0, sizeof(*iq));
140 iq->state = INIT_REQUEST_STATE;
141 iq->final_state = FINISHED_STATE;
142 iq->an_prepend_list = NULL;
143 iq->an_prepend_last = NULL;
144 iq->ns_prepend_list = NULL;
145 iq->ns_prepend_last = NULL;
146 iq->dp = NULL;
147 iq->depth = 0;
148 iq->num_target_queries = 0;
149 iq->num_current_queries = 0;
150 iq->query_restart_count = 0;
151 iq->referral_count = 0;
152 iq->sent_count = 0;
153 iq->ratelimit_ok = 0;
154 iq->target_count = NULL;
155 iq->dp_target_count = 0;
156 iq->wait_priming_stub = 0;
157 iq->refetch_glue = 0;
158 iq->dnssec_expected = 0;
159 iq->dnssec_lame_query = 0;
160 iq->chase_flags = qstate->query_flags;
162 iq->qchase = qstate->qinfo;
163 outbound_list_init(&iq->outlist);
164 iq->minimise_count = 0;
165 iq->timeout_count = 0;
167 iq->minimisation_state = INIT_MINIMISE_STATE;
169 iq->minimisation_state = DONOT_MINIMISE_STATE;
171 memset(&iq->qinfo_out, 0, sizeof(struct query_info));
179 * @param iq: iterator query state
186 next_state(struct iter_qstate* iq, enum iter_state nextstate)
191 if(iq->response == NULL) {
196 iq->state = nextstate;
208 * @param iq: iterator query state
213 final_state(struct iter_qstate* iq)
215 return next_state(iq, iq->final_state);
397 iter_prepend(struct iter_qstate* iq, struct dns_msg* msg,
403 for(p = iq->an_prepend_list; p; p = p->next)
405 for(p = iq->ns_prepend_list; p; p = p->next)
418 for(p = iq->an_prepend_list; p; p = p->next) {
427 for(p = iq->ns_prepend_list; p; p = p->next) {
454 * @param iq: iterator query state.
459 iter_find_rrset_in_prepend_answer(struct iter_qstate* iq,
462 struct iter_prep_list* p = iq->an_prepend_list;
477 * @param iq: iterator query state.
482 iter_add_prepend_answer(struct module_qstate* qstate, struct iter_qstate* iq,
492 if(iq->an_prepend_last)
493 iq->an_prepend_last->next = p;
494 else iq->an_prepend_list = p;
495 iq->an_prepend_last = p;
502 * @param iq: iterator query state.
507 iter_add_prepend_auth(struct module_qstate* qstate, struct iter_qstate* iq,
517 if(iq->ns_prepend_last)
518 iq->ns_prepend_last->next = p;
519 else iq->ns_prepend_list = p;
520 iq->ns_prepend_last = p;
532 * @param iq: iterator query state.
539 handle_cname_response(struct module_qstate* qstate, struct iter_qstate* iq,
544 *mname = iq->qchase.qname;
545 *mname_len = iq->qchase.qname_len;
557 !iter_find_rrset_in_prepend_answer(iq, r)) {
558 if(!iter_add_prepend_answer(qstate, iq, r))
565 !iter_find_rrset_in_prepend_answer(iq, r)) {
567 if(!iter_add_prepend_answer(qstate, iq, r))
581 if(!iter_add_prepend_auth(qstate, iq, r))
619 is_caps_whitelisted(struct iter_env* ie, struct iter_qstate* iq)
622 return name_tree_lookup(ie->caps_white, iq->qchase.qname,
623 iq->qchase.qname_len, dname_count_labels(iq->qchase.qname),
624 iq->qchase.qclass) != NULL;
629 target_count_create(struct iter_qstate* iq)
631 if(!iq->target_count) {
632 iq->target_count = (int*)calloc(3, sizeof(int));
634 if(iq->target_count)
635 iq->target_count[0] = 1;
640 target_count_increase(struct iter_qstate* iq, int num)
642 target_count_create(iq);
643 if(iq->target_count)
644 iq->target_count[1] += num;
645 iq->dp_target_count++;
649 target_count_increase_nx(struct iter_qstate* iq, int num)
651 target_count_create(iq);
652 if(iq->target_count)
653 iq->target_count[2] += num;
668 * @param iq: The iterator state that is generating this event.
682 struct iter_qstate* iq, enum iter_state initial_state,
746 target_count_create(iq);
747 subiq->target_count = iq->target_count;
748 if(iq->target_count)
749 iq->target_count[0] ++; /* extra reference */
752 subiq->depth = iq->depth+1;
771 * @param iq: iterator query state.
777 prime_root(struct module_qstate* qstate, struct iter_qstate* iq, int id,
793 qclass, qstate, id, iq, QUERYTARGETS_STATE, PRIME_RESP_STATE,
828 * @param iq: iterator query state.
838 prime_stub(struct module_qstate* qstate, struct iter_qstate* iq, int id,
848 stub = hints_lookup_stub(qstate->env->hints, qname, qclass, iq->dp);
855 if(!iq->auth_zone_avoid && iq->dp && iq->dp->auth_dp &&
856 query_dname_compare(iq->dp->name, stub_dp->name) == 0)
862 if(iq->dp == NULL) r = 2;
865 iq->dp = delegpt_copy(stub_dp, qstate->region);
866 if(!iq->dp) {
884 LDNS_RR_TYPE_NS, qclass, qstate, id, iq,
926 auth_zone_delegpt(struct module_qstate* qstate, struct iter_qstate* iq,
930 if(iq->auth_zone_avoid)
933 delname = iq->qchase.qname;
934 delnamelen = iq->qchase.qname_len;
946 if(iq->dp && query_dname_compare(z->name, iq->dp->name) == 0
947 && iq->dp->auth_dp && qstate->blacklist &&
959 iq->dp = NULL;
962 if(iq->dp==NULL || dname_subdomain_c(z->name, iq->dp->name)) {
1005 iq->dp = dp;
1018 * @param iq: iterator query state.
1022 generate_a_aaaa_check(struct module_qstate* qstate, struct iter_qstate* iq,
1028 struct reply_info* rep = iq->response->rep;
1030 log_assert(iq->dp);
1032 if(iq->depth == ie->max_dependency_depth)
1059 qstate, id, iq,
1073 * @param iq: iterator query state.
1077 generate_ns_check(struct module_qstate* qstate, struct iter_qstate* iq, int id)
1081 log_assert(iq->dp);
1083 if(iq->depth == ie->max_dependency_depth)
1085 if(!can_have_last_resort(qstate->env, iq->dp->name, iq->dp->namelen,
1086 iq->qchase.qclass, NULL))
1090 query_dname_compare(iq->dp->name, qstate->qinfo.qname)==0 &&
1093 generate_a_aaaa_check(qstate, iq, id);
1101 iq->dp->name, LDNS_RR_TYPE_NS, iq->qchase.qclass);
1102 if(!generate_sub_request(iq->dp->name, iq->dp->namelen,
1103 LDNS_RR_TYPE_NS, iq->qchase.qclass, qstate, id, iq,
1115 subiq->dp = delegpt_copy(iq->dp, subq->region);
1139 * @param iq: iterator query state.
1144 struct iter_qstate* iq, int id)
1147 log_assert(iq->dp);
1151 query_dname_compare(iq->dp->name, qstate->qinfo.qname)==0 &&
1158 iq->dp->name, LDNS_RR_TYPE_DNSKEY, iq->qchase.qclass);
1159 if(!generate_sub_request(iq->dp->name, iq->dp->namelen,
1160 LDNS_RR_TYPE_DNSKEY, iq->qchase.qclass, qstate, id, iq,
1171 subiq->dp = delegpt_copy(iq->dp, subq->region);
1180 * @param iq: iterator query state.
1182 * If returns true but, iq->dp is NULL then a malloc failure occurred.
1185 forward_request(struct module_qstate* qstate, struct iter_qstate* iq)
1188 uint8_t* delname = iq->qchase.qname;
1189 size_t delnamelen = iq->qchase.qname_len;
1190 if(iq->refetch_glue && iq->dp) {
1191 delname = iq->dp->name;
1192 delnamelen = iq->dp->namelen;
1195 if( (iq->qchase.qtype == LDNS_RR_TYPE_DS || iq->refetch_glue)
1196 && !dname_is_root(iq->qchase.qname))
1198 dp = forwards_lookup(qstate->env->fwds, delname, iq->qchase.qclass);
1202 iq->chase_flags |= BIT_RD;
1203 iq->dp = delegpt_copy(dp, qstate->region);
1204 /* iq->dp checked by caller */
1221 * @param iq: iterator query state.
1228 processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq,
1240 if(iq->query_restart_count > MAX_RESTART_COUNT) {
1242 " of query restarts with %d", iq->query_restart_count);
1245 if(iq->qchase.qname)
1246 errinf_dname(qstate, "stop at", iq->qchase.qname);
1254 verbose(VERB_ALGO, "request has dependency depth of %d", iq->depth);
1255 if(iq->depth > ie->max_dependency_depth) {
1257 "dependency depth with depth of %d", iq->depth);
1265 iq->qchase.qclass = 0;
1266 return next_state(iq, COLLECT_CLASS_STATE);
1272 * we won���t try to re-fetch glue if the iq->dp is null.
1274 if (iq->refetch_glue &&
1275 iq->dp &&
1276 !can_have_last_resort(qstate->env, iq->dp->name,
1277 iq->dp->namelen, iq->qchase.qclass, NULL)) {
1278 iq->refetch_glue = 0;
1286 if (iter_stub_fwd_no_cache(qstate, &iq->qchase)) {
1298 msg = dns_cache_lookup(qstate->env, iq->qchase.qname,
1299 iq->qchase.qname_len, iq->qchase.qtype,
1300 iq->qchase.qclass, qstate->query_flags,
1303 iter_qname_indicates_dnssec(qstate->env, &iq->qchase)) {
1306 msg = val_neg_getmsg(qstate->env->neg_cache, &iq->qchase,
1315 iq->qchase.qname) != 0)
1321 &iq->qchase);
1335 if(!handle_cname_response(qstate, iq, msg,
1342 iq->qchase.qname = sname;
1343 iq->qchase.qname_len = slen;
1346 iq->dp = NULL;
1347 iq->refetch_glue = 0;
1348 iq->query_restart_count++;
1349 iq->sent_count = 0;
1350 iq->dp_target_count = 0;
1353 iq->minimisation_state = INIT_MINIMISE_STATE;
1354 return next_state(iq, INIT_REQUEST_STATE);
1364 iq->response = msg;
1365 return final_state(iq);
1369 if(forward_request(qstate, iq))
1371 if(!iq->dp) {
1376 iq->refetch_glue = 0;
1377 iq->minimisation_state = DONOT_MINIMISE_STATE;
1381 return next_state(iq, QUERYTARGETS_STATE);
1390 if(iq->refetch_glue) {
1391 if(!iq->dp) {
1396 delname = iq->dp->name;
1397 delnamelen = iq->dp->namelen;
1399 delname = iq->qchase.qname;
1400 delnamelen = iq->qchase.qname_len;
1402 if(iq->qchase.qtype == LDNS_RR_TYPE_DS || iq->refetch_glue ||
1403 (iq->qchase.qtype == LDNS_RR_TYPE_NS && qstate->prefetch_leeway
1404 && can_have_last_resort(qstate->env, delname, delnamelen, iq->qchase.qclass, NULL))) {
1410 if(dname_is_root(delname) && (iq->refetch_glue ||
1411 (iq->qchase.qtype == LDNS_RR_TYPE_NS &&
1422 iq->dp = dns_cache_find_delegation(qstate->env, delname,
1423 delnamelen, iq->qchase.qtype, iq->qchase.qclass,
1424 qstate->region, &iq->deleg_msg,
1426 else iq->dp = NULL;
1430 if(iq->dp == NULL) {
1433 if(!auth_zone_delegpt(qstate, iq, delname, delnamelen))
1436 if(iq->dp) /* use auth zone dp */
1437 return next_state(iq, INIT_REQUEST_2_STATE);
1439 r = prime_stub(qstate, iq, id, delname,
1440 iq->qchase.qclass);
1446 iq->qchase.qclass)) {
1449 iq->dp = hints_lookup_root(qstate->env->hints,
1450 iq->qchase.qclass);
1451 if(!iq->dp) {
1457 iq->dp = delegpt_copy(iq->dp, qstate->region);
1458 if(!iq->dp) {
1464 return next_state(iq, INIT_REQUEST_2_STATE);
1468 if(!prime_root(qstate, iq, id, iq->qchase.qclass))
1478 if(!iq->ratelimit_ok && qstate->prefetch_leeway)
1479 iq->ratelimit_ok = 1; /* allow prefetches, this keeps
1481 if(!iq->ratelimit_ok && infra_ratelimit_exceeded(
1482 qstate->env->infra_cache, iq->dp->name,
1483 iq->dp->namelen, *qstate->env->now)) {
1487 iq->dp->name, iq->dp->namelen,
1494 iq->ratelimit_ok = 1;
1496 "delegation point", iq->dp->name,
1503 "delegation point", iq->dp->name,
1507 errinf_dname(qstate, "for zone", iq->dp->name);
1525 iq->dp)) {
1527 if(!can_have_last_resort(qstate->env, iq->dp->name, iq->dp->namelen, iq->qchase.qclass, &retdp)) {
1532 iq->dp = delegpt_copy(retdp,
1534 if(!iq->dp) {
1545 delegpt_log(VERB_ALGO, iq->dp);
1548 errinf_dname(qstate, "for zone", iq->dp->name);
1552 if(dname_is_root(iq->dp->name)) {
1556 iq->dp = hints_lookup_root(qstate->env->hints,
1557 iq->qchase.qclass);
1560 if(!iq->dp) {
1565 iq->dp = delegpt_copy(iq->dp, qstate->region);
1566 if(!iq->dp) {
1576 delegpt_log(VERB_ALGO, iq->dp);
1578 delname = iq->dp->name;
1579 delnamelen = iq->dp->namelen;
1586 delegpt_log(VERB_ALGO, iq->dp);
1590 return next_state(iq, INIT_REQUEST_2_STATE);
1603 * @param iq: iterator query state.
1609 processInitRequest2(struct module_qstate* qstate, struct iter_qstate* iq,
1617 delname = iq->qchase.qname;
1618 delnamelen = iq->qchase.qname_len;
1619 if(iq->refetch_glue) {
1621 if(!iq->dp) {
1629 qstate->env->hints, iq->qchase.qname, iq->qchase.qclass,
1630 iq->dp);
1632 dname_subdomain_c(iq->dp->name, stub->dp->name)) {
1633 delname = iq->dp->name;
1634 delnamelen = iq->dp->namelen;
1637 if(iq->qchase.qtype == LDNS_RR_TYPE_DS || iq->refetch_glue) {
1640 iq->refetch_glue = 0; /* if CNAME causes restart, no refetch */
1645 if(!auth_zone_delegpt(qstate, iq, delname, delnamelen))
1649 if(prime_stub(qstate, iq, id, delname, iq->qchase.qclass)) {
1655 return next_state(iq, INIT_REQUEST_3_STATE);
1665 * @param iq: iterator query state.
1670 processInitRequest3(struct module_qstate* qstate, struct iter_qstate* iq,
1677 iq->dnssec_expected = iter_indicates_dnssec(qstate->env, iq->dp,
1678 iq->deleg_msg, iq->qchase.qclass);
1682 if(!(qstate->query_flags & BIT_RD) && iq->deleg_msg) {
1683 iq->response = iq->deleg_msg;
1684 if(verbosity >= VERB_ALGO && iq->response)
1686 &iq->response->qinfo, iq->response->rep);
1689 return final_state(iq);
1693 iq->chase_flags &= ~BIT_RD;
1696 if(iq->dnssec_expected && qstate->env->cfg->prefetch_key &&
1698 generate_dnskey_prefetch(qstate, iq, id);
1705 return next_state(iq, QUERYTARGETS_STATE);
1714 * @param iq: iterator query state.
1724 struct iter_qstate* iq, int id, uint8_t* name, size_t namelen,
1729 id, iq, INIT_REQUEST_STATE, FINISHED_STATE, &subq, 0, 0))
1737 if(dname_subdomain_c(name, iq->dp->name)) {
1738 subiq->dp = delegpt_copy(iq->dp, subq->region);
1766 * @param iq: iterator query state.
1775 generate_target_query(struct module_qstate* qstate, struct iter_qstate* iq,
1780 id, iq, INIT_REQUEST_STATE, FINISHED_STATE, &subq, 0, 0))
1791 * @param iq: iterator query state.
1801 query_for_targets(struct module_qstate* qstate, struct iter_qstate* iq,
1809 if(iq->depth == ie->max_dependency_depth)
1811 if(iq->depth > 0 && iq->target_count &&
1812 iq->target_count[1] > MAX_TARGET_COUNT) {
1816 "number of glue fetches %d", s, iq->target_count[1]);
1819 if(iq->dp_target_count > MAX_DP_TARGET_COUNT) {
1824 s, iq->dp_target_count);
1828 iter_mark_cycle_targets(qstate, iq->dp);
1829 missing = (int)delegpt_count_missing_targets(iq->dp);
1846 for(ns = iq->dp->nslist; ns; ns = ns->next) {
1860 if(!generate_target_query(qstate, iq, id,
1862 LDNS_RR_TYPE_AAAA, iq->qchase.qclass)) {
1872 if(!generate_target_query(qstate, iq, id,
1874 LDNS_RR_TYPE_A, iq->qchase.qclass)) {
1903 * @param iq: iterator query state.
1910 processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
1916 log_assert(iq->dp);
1918 if(!can_have_last_resort(qstate->env, iq->dp->name, iq->dp->namelen,
1919 iq->qchase.qclass, NULL)) {
1923 errinf_dname(qstate, "at zone", iq->dp->name);
1927 if(!iq->dp->has_parent_side_NS && dname_is_root(iq->dp->name)) {
1929 iq->qchase.qclass);
1932 iq->chase_flags &= ~BIT_RD; /* go to authorities */
1934 (void)delegpt_add_ns(iq->dp, qstate->region,
1938 (void)delegpt_add_addr(iq->dp, qstate->region,
1943 iq->dp->has_parent_side_NS = 1;
1944 } else if(!iq->dp->has_parent_side_NS) {
1945 if(!iter_lookup_parent_NS_from_cache(qstate->env, iq->dp,
1947 || !iq->dp->has_parent_side_NS) {
1951 iq->store_parent_NS = iq->dp;
1952 iq->chase_flags &= ~BIT_RD; /* go to authorities */
1953 iq->deleg_msg = NULL;
1954 iq->refetch_glue = 1;
1955 iq->query_restart_count++;
1956 iq->sent_count = 0;
1957 iq->dp_target_count = 0;
1959 iq->minimisation_state = INIT_MINIMISE_STATE;
1960 return next_state(iq, INIT_REQUEST_STATE);
1964 if(!cache_fill_missing(qstate->env, iq->qchase.qclass,
1965 qstate->region, iq->dp))
1967 if(iq->dp->usable_list) {
1969 return next_state(iq, QUERYTARGETS_STATE);
1972 if(iter_lookup_parent_glue_from_cache(qstate->env, iq->dp,
1976 return next_state(iq, QUERYTARGETS_STATE);
1979 if(delegpt_count_missing_targets(iq->dp) > 0) {
1982 if(!query_for_targets(qstate, iq, ie, id, 1, &qs)) {
1984 errinf_dname(qstate, "at zone", iq->dp->name);
1987 iq->num_target_queries += qs;
1988 target_count_increase(iq, qs);
1994 if(iq->depth == ie->max_dependency_depth) {
1999 if(iq->depth > 0 && iq->target_count &&
2000 iq->target_count[1] > MAX_TARGET_COUNT) {
2004 "number of glue fetches %d", s, iq->target_count[1]);
2009 iter_mark_pside_cycle_targets(qstate, iq->dp);
2012 for(ns = iq->dp->nslist; ns; ns = ns->next) {
2018 iq->qchase.qclass, NULL)) {
2021 ns->name, LDNS_RR_TYPE_NS, iq->qchase.qclass);
2029 if(!generate_parentside_target_query(qstate, iq, id,
2031 LDNS_RR_TYPE_AAAA, iq->qchase.qclass)) {
2041 if(!generate_parentside_target_query(qstate, iq, id,
2043 LDNS_RR_TYPE_A, iq->qchase.qclass)) {
2053 iq->num_target_queries += query_count;
2054 target_count_increase(iq, query_count);
2062 if(!qstate->no_cache_store && iq->query_for_pside_glue
2063 && !iq->pside_glue)
2065 iq->deleg_msg?iq->deleg_msg->rep:
2066 (iq->response?iq->response->rep:NULL));
2069 errinf_dname(qstate, "at zone", iq->dp->name);
2084 * @param iq: iterator query state.
2091 processDSNSFind(struct module_qstate* qstate, struct iter_qstate* iq, int id)
2096 if(!iq->dsns_point) {
2098 iq->dsns_point = iq->qchase.qname;
2099 iq->dsns_point_len = iq->qchase.qname_len;
2102 if(!dname_subdomain_c(iq->dsns_point, iq->dp->name)) {
2103 errinf_dname(qstate, "for DS query parent-child nameserver search the query is not under the zone", iq->dp->name);
2108 dname_remove_label(&iq->dsns_point, &iq->dsns_point_len);
2109 if(query_dname_compare(iq->dsns_point, iq->dp->name) == 0) {
2113 iq->state = QUERYTARGETS_STATE;
2116 iq->state = DSNS_FIND_STATE;
2120 iq->dsns_point, LDNS_RR_TYPE_NS, iq->qchase.qclass);
2121 if(!generate_sub_request(iq->dsns_point, iq->dsns_point_len,
2122 LDNS_RR_TYPE_NS, iq->qchase.qclass, qstate, id, iq,
2124 errinf_dname(qstate, "for DS query parent-child nameserver search, could not generate NS lookup for", iq->dsns_point);
2140 * @param iq: iterator query state.
2148 processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq,
2164 "currentqueries %d sentcount %d", iq->num_target_queries,
2165 iq->num_current_queries, iq->sent_count);
2169 if(iq->referral_count > MAX_REFERRAL_COUNT) {
2171 "number of referrrals with %d", iq->referral_count);
2175 if(iq->sent_count > MAX_SENT_COUNT) {
2177 "number of sends with %d", iq->sent_count);
2181 if(iq->target_count && iq->target_count[2] > MAX_TARGET_NX) {
2184 iq->target_count[2]);
2191 if(!iq->dp) {
2197 delegpt_no_ipv6(iq->dp);
2199 delegpt_no_ipv4(iq->dp);
2200 delegpt_log(VERB_ALGO, iq->dp);
2202 if(iq->num_current_queries>0) {
2211 if(iq->minimisation_state == INIT_MINIMISE_STATE
2212 && !(iq->chase_flags & BIT_RD)) {
2217 if(!(iq->qinfo_out.qname_len
2218 && dname_subdomain_c(iq->qchase.qname,
2219 iq->qinfo_out.qname)
2220 && dname_subdomain_c(iq->qinfo_out.qname,
2221 iq->dp->name))) {
2222 iq->qinfo_out.qname = iq->dp->name;
2223 iq->qinfo_out.qname_len = iq->dp->namelen;
2224 iq->qinfo_out.qtype = LDNS_RR_TYPE_A;
2225 iq->qinfo_out.qclass = iq->qchase.qclass;
2226 iq->qinfo_out.local_alias = NULL;
2227 iq->minimise_count = 0;
2230 iq->minimisation_state = MINIMISE_STATE;
2232 if(iq->minimisation_state == MINIMISE_STATE) {
2233 int qchaselabs = dname_count_labels(iq->qchase.qname);
2235 dname_count_labels(iq->qinfo_out.qname);
2237 qout_orig = iq->qinfo_out.qname;
2238 qout_orig_len = iq->qinfo_out.qname_len;
2239 iq->qinfo_out.qname = iq->qchase.qname;
2240 iq->qinfo_out.qname_len = iq->qchase.qname_len;
2241 iq->minimise_count++;
2242 iq->timeout_count = 0;
2244 iter_dec_attempts(iq->dp, 1);
2251 iq->minimise_count > MINIMISE_ONE_LAB) {
2252 if(iq->minimise_count < MAX_MINIMISE_COUNT) {
2258 if (MAX_MINIMISE_COUNT - iq->minimise_count >=
2277 dname_remove_labels(&iq->qinfo_out.qname,
2278 &iq->qinfo_out.qname_len,
2282 && (iq->qchase.qtype == LDNS_RR_TYPE_DS
2283 || iq->qchase.qtype == LDNS_RR_TYPE_A)))
2285 iq->minimisation_state = DONOT_MINIMISE_STATE;
2288 iq->qinfo_out.qname, iq->qinfo_out.qname_len,
2289 iq->qinfo_out.qtype, iq->qinfo_out.qclass,
2302 iq->response = msg;
2303 return final_state(iq);
2308 iq->qinfo_out.qname,
2309 iq->qinfo_out.qname_len,
2310 iq->qinfo_out.qtype,
2311 iq->qinfo_out.qclass,
2312 qstate, id, iq,
2329 if(iq->minimisation_state == SKIP_MINIMISE_STATE) {
2330 if(iq->timeout_count < MAX_MINIMISE_TIMEOUT_COUNT)
2333 iq->minimisation_state = MINIMISE_STATE;
2337 iq->minimisation_state = DONOT_MINIMISE_STATE;
2339 if(iq->minimisation_state == DONOT_MINIMISE_STATE)
2340 iq->qinfo_out = iq->qchase;
2346 if(!iq->auth_zone_avoid && qstate->blacklist) {
2348 iq->dp->name, iq->dp->namelen, iq->qinfo_out.qclass)) {
2352 iq->auth_zone_avoid = 1;
2355 if(iq->auth_zone_avoid) {
2356 iq->auth_zone_avoid = 0;
2358 } else if(auth_zones_lookup(qstate->env->auth_zones, &iq->qinfo_out,
2359 qstate->region, &iq->response, &auth_fallback, iq->dp->name,
2360 iq->dp->namelen)) {
2364 &iq->response->qinfo, iq->response->rep);
2366 if((iq->chase_flags&BIT_RD) && !(iq->response->rep->flags&BIT_AA)) {
2372 iq->num_current_queries++;
2373 iq->chase_to_rd = 0;
2374 iq->dnssec_lame_query = 0;
2375 iq->auth_zone_response = 1;
2376 return next_state(iq, QUERY_RESP_STATE);
2379 iq->auth_zone_response = 0;
2388 if(iq->dp->auth_dp) {
2391 iq->auth_zone_avoid = 1;
2392 return next_state(iq, INIT_REQUEST_STATE);
2401 if(iq->depth < ie->max_dependency_depth
2402 && iq->num_target_queries == 0
2403 && (!iq->target_count || iq->target_count[2]==0)
2404 && iq->sent_count < TARGET_FETCH_STOP) {
2405 tf_policy = ie->target_fetch_policy[iq->depth];
2409 if(iq->caps_fallback) {
2412 if(!query_for_targets(qstate, iq, ie, id, -1, &extra)) {
2416 iq->num_target_queries += extra;
2417 target_count_increase(iq, extra);
2418 if(iq->num_target_queries > 0) {
2424 if(qout_orig && iq->minimise_count > 0) {
2425 iq->minimise_count--;
2426 iq->qinfo_out.qname = qout_orig;
2427 iq->qinfo_out.qname_len = qout_orig_len;
2432 delegpt_count_addr(iq->dp, &naddr, &nres, &navail);
2436 if(iq->caps_server+1 >= naddr*3 ||
2437 iq->caps_server*2+2 >= MAX_SENT_COUNT) {
2442 (int)iq->caps_server+1, (int)naddr*3);
2443 iq->response = iq->caps_response;
2444 iq->caps_fallback = 0;
2445 iter_dec_attempts(iq->dp, 3); /* space for fallback */
2446 iq->num_current_queries++; /* RespState decrements it*/
2447 iq->referral_count++; /* make sure we don't loop */
2448 iq->sent_count = 0;
2449 iq->dp_target_count = 0;
2450 iq->state = QUERY_RESP_STATE;
2454 (int)iq->caps_server);
2464 (void)query_for_targets(qstate, iq, ie, id, tf_policy, &extra);
2467 iq->num_target_queries += extra;
2468 target_count_increase(iq, extra);
2472 delegpt_add_unused_targets(iq->dp);
2475 target = iter_server_selection(ie, qstate->env, iq->dp,
2476 iq->dp->name, iq->dp->namelen, iq->qchase.qtype,
2477 &iq->dnssec_lame_query, &iq->chase_to_rd,
2478 iq->num_target_queries, qstate->blacklist,
2492 if(iq->num_target_queries==0 && iq->num_current_queries==0) {
2496 if(delegpt_count_missing_targets(iq->dp) > 0) {
2500 if(!query_for_targets(qstate, iq, ie, id,
2503 errinf_dname(qstate, "at zone", iq->dp->name);
2508 delegpt_count_missing_targets(iq->dp) == 0){
2516 iq->num_target_queries += qs;
2517 target_count_increase(iq, qs);
2521 if(iq->num_target_queries == 0) {
2525 if(iq->caps_fallback && iq->caps_reply) {
2530 (int)iq->caps_server+1);
2531 iq->response = iq->caps_response;
2532 iq->caps_fallback = 0;
2533 iter_dec_attempts(iq->dp, 3); /* space for fallback */
2534 iq->num_current_queries++; /* RespState decrements it*/
2535 iq->referral_count++; /* make sure we don't loop */
2536 iq->sent_count = 0;
2537 iq->dp_target_count = 0;
2538 iq->state = QUERY_RESP_STATE;
2541 return processLastResort(qstate, iq, ie, id);
2547 if(iq->num_target_queries>0 && iq->num_current_queries>0) {
2550 " queries to respond", iq->num_target_queries,
2551 iq->num_current_queries);
2553 } else if(iq->num_target_queries>0) {
2556 iq->num_target_queries);
2561 iq->num_current_queries);
2566 if(qout_orig && iq->minimise_count > 0) {
2567 iq->minimise_count--;
2568 iq->qinfo_out.qname = qout_orig;
2569 iq->qinfo_out.qname_len = qout_orig_len;
2575 if(!(iq->chase_flags & BIT_RD) && !iq->ratelimit_ok) {
2576 if(!infra_ratelimit_inc(qstate->env->infra_cache, iq->dp->name,
2577 iq->dp->namelen, *qstate->env->now, &qstate->qinfo,
2585 iq->dp->name);
2592 log_query_info(VERB_QUERY, "sending query:", &iq->qinfo_out);
2593 log_name_addr(VERB_QUERY, "sending to target:", iq->dp->name,
2596 iq->dnssec_expected?"expected": "not expected",
2597 iq->dnssec_lame_query?" but lame_query anyway": "");
2600 outq = (*qstate->env->send_query)(&iq->qinfo_out,
2601 iq->chase_flags | (iq->chase_to_rd?BIT_RD:0),
2605 EDNS_DO| ((iq->chase_to_rd||(iq->chase_flags&BIT_RD)!=0)&&
2607 &iq->qinfo_out)||target->attempts==1)?0:BIT_CD),
2608 iq->dnssec_expected, iq->caps_fallback || is_caps_whitelisted(
2609 ie, iq), &target->addr, target->addrlen,
2610 iq->dp->name, iq->dp->namelen,
2611 (iq->dp->ssl_upstream || qstate->env->cfg->ssl_upstream),
2616 if(!(iq->chase_flags & BIT_RD) && !iq->ratelimit_ok)
2617 infra_ratelimit_dec(qstate->env->infra_cache, iq->dp->name,
2618 iq->dp->namelen, *qstate->env->now);
2620 iq->minimisation_state = SKIP_MINIMISE_STATE;
2621 return next_state(iq, QUERYTARGETS_STATE);
2623 outbound_list_insert(&iq->outlist, outq);
2624 iq->num_current_queries++;
2625 iq->sent_count++;
2651 * @param iq: iterator query state.
2658 processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq,
2663 iq->num_current_queries--;
2665 if(!inplace_cb_query_response_call(qstate->env, qstate, iq->response))
2668 if(iq->response == NULL) {
2671 iq->minimisation_state = SKIP_MINIMISE_STATE;
2673 iq->timeout_count++;
2674 iq->chase_to_rd = 0;
2675 iq->dnssec_lame_query = 0;
2677 return next_state(iq, QUERYTARGETS_STATE);
2679 iq->timeout_count = 0;
2681 (int)((iq->chase_flags&BIT_RD) || iq->chase_to_rd),
2682 iq->response, &iq->qinfo_out, iq->dp);
2683 iq->chase_to_rd = 0;
2684 if(type == RESPONSE_TYPE_REFERRAL && (iq->chase_flags&BIT_RD) &&
2685 !iq->auth_zone_response) {
2690 if(!qstate->env->cfg->disable_dnssec_lame_check && iq->dnssec_expected
2691 && !iq->dnssec_lame_query &&
2692 !(iq->chase_flags&BIT_RD)
2693 && iq->sent_count < DNSSEC_LAME_DETECT_COUNT
2700 if(!iter_msg_has_dnssec(iq->response)) {
2707 iq->dp, &qstate->reply->addr,
2714 if(!iter_msg_from_zone(iq->response, iq->dp, type,
2715 iq->qchase.qclass))
2720 } else iq->dnssec_lame_query = 0;
2724 iq->response->rep, iq->response->rep->an_numrrsets,
2725 iq->response->rep->an_numrrsets
2726 + iq->response->rep->ns_numrrsets);
2727 if(!ns) ns = find_NS(iq->response->rep, 0,
2728 iq->response->rep->an_numrrsets);
2729 if(!ns || !dname_strict_subdomain_c(ns->rk.dname, iq->dp->name)
2730 || !dname_subdomain_c(iq->qchase.qname, ns->rk.dname)){
2734 iter_scrub_ds(iq->response, ns, iq->dp->name);
2735 } else iter_scrub_ds(iq->response, NULL, NULL);
2737 FLAGS_GET_RCODE(iq->response->rep->flags) == LDNS_RCODE_YXDOMAIN) {
2741 if(type == RESPONSE_TYPE_CNAME && iq->response->rep->an_numrrsets >= 1
2742 && ntohs(iq->response->rep->rrsets[0]->rk.type) == LDNS_RR_TYPE_DNAME) {
2745 get_cname_target(iq->response->rep->rrsets[0], &sname,
2747 if(snamelen && dname_subdomain_c(sname, iq->response->rep->rrsets[0]->rk.dname)) {
2752 iq->qchase.qtype == LDNS_RR_TYPE_CNAME &&
2753 iq->minimisation_state == MINIMISE_STATE &&
2754 query_dname_compare(iq->qchase.qname, iq->qinfo_out.qname) == 0) {
2768 FLAGS_GET_RCODE(iq->response->rep->flags)
2770 (iq->response->rep->an_numrrsets?"ANSWER":
2775 if(iq->qchase.qtype == LDNS_RR_TYPE_DS && !iq->dsns_point
2776 && !(iq->chase_flags&BIT_RD)
2777 && iter_ds_toolow(iq->response, iq->dp)
2778 && iter_dp_cangodown(&iq->qchase, iq->dp)) {
2780 outbound_list_clear(&iq->outlist);
2781 iq->num_current_queries = 0;
2785 iq->num_target_queries = 0;
2786 return processDSNSFind(qstate, iq, id);
2789 iter_dns_store(qstate->env, &iq->response->qinfo,
2790 iq->response->rep, 0, qstate->prefetch_leeway,
2791 iq->dp&&iq->dp->has_parent_side_NS,
2794 outbound_list_clear(&iq->outlist);
2795 iq->num_current_queries = 0;
2799 iq->num_target_queries = 0;
2804 if(iq->minimisation_state != DONOT_MINIMISE_STATE
2805 && !(iq->chase_flags & BIT_RD)) {
2806 if(FLAGS_GET_RCODE(iq->response->rep->flags) !=
2809 if(FLAGS_GET_RCODE(iq->response->rep->flags) ==
2811 iter_scrub_nxdomain(iq->response);
2812 return final_state(iq);
2820 iq->minimisation_state = DONOT_MINIMISE_STATE;
2822 if(FLAGS_GET_RCODE(iq->response->rep->flags) ==
2828 if(iq->dnssec_expected)
2829 return final_state(iq);
2838 &iq->response->qinfo);
2840 iq->response->qinfo.qname,
2841 iq->response->qinfo.qname_len,
2842 iq->response->qinfo.qtype,
2843 iq->response->qinfo.qclass,
2844 qstate, id, iq,
2852 return next_state(iq, QUERYTARGETS_STATE);
2854 return final_state(iq);
2860 if(!(iq->chase_flags & BIT_RD) && !iq->ratelimit_ok) {
2864 iq->dp->name, iq->dp->namelen,
2878 reply_find_rrset_section_ns(iq->response->rep,
2879 iq->qchase.qname, iq->qchase.qname_len,
2880 LDNS_RR_TYPE_NS, iq->qchase.qclass)
2881 || reply_find_rrset_section_an(iq->response->rep,
2882 iq->qchase.qname, iq->qchase.qname_len,
2883 LDNS_RR_TYPE_NS, iq->qchase.qclass)
2888 iter_dns_store(qstate->env, &iq->response->qinfo,
2889 iq->response->rep, 1, 0, 0, NULL, 0);
2890 if(iq->store_parent_NS)
2892 iq->response->rep);
2895 iq->response->rep, iq->dp->name);
2898 if(!qstate->no_cache_store && iq->query_for_pside_glue
2899 && !iq->pside_glue) {
2900 iq->pside_glue = reply_find_rrset(iq->response->rep,
2901 iq->qchase.qname, iq->qchase.qname_len,
2902 iq->qchase.qtype, iq->qchase.qclass);
2903 if(iq->pside_glue) {
2905 "glue", iq->pside_glue);
2907 iq->pside_glue);
2913 iq->deleg_msg = iq->response;
2914 iq->dp = delegpt_from_message(iq->response, qstate->region);
2916 iq->minimisation_state = INIT_MINIMISE_STATE;
2917 if(!iq->dp) {
2921 if(!cache_fill_missing(qstate->env, iq->qchase.qclass,
2922 qstate->region, iq->dp)) {
2926 if(iq->store_parent_NS && query_dname_compare(iq->dp->name,
2927 iq->store_parent_NS->name) == 0)
2928 iter_merge_retry_counts(iq->dp, iq->store_parent_NS);
2929 delegpt_log(VERB_ALGO, iq->dp);
2931 iq->referral_count++;
2932 iq->sent_count = 0;
2933 iq->dp_target_count = 0;
2936 iq->dnssec_expected = iter_indicates_dnssec(qstate->env,
2937 iq->dp, iq->response, iq->qchase.qclass);
2939 if(iq->dnssec_expected && qstate->env->cfg->prefetch_key &&
2941 generate_dnskey_prefetch(qstate, iq, id);
2948 generate_ns_check(qstate, iq, id);
2954 outbound_list_clear(&iq->outlist);
2955 iq->num_current_queries = 0;
2959 iq->num_target_queries = 0;
2961 return next_state(iq, QUERYTARGETS_STATE);
2970 log_dns_msg("cname msg", &iq->response->qinfo,
2971 iq->response->rep);
2974 if(iq->qchase.qtype == LDNS_RR_TYPE_DS && !iq->dsns_point
2975 && !(iq->chase_flags&BIT_RD)
2976 && iter_ds_toolow(iq->response, iq->dp)
2977 && iter_dp_cangodown(&iq->qchase, iq->dp)) {
2978 outbound_list_clear(&iq->outlist);
2979 iq->num_current_queries = 0;
2983 iq->num_target_queries = 0;
2984 return processDSNSFind(qstate, iq, id);
2987 if(!handle_cname_response(qstate, iq, iq->response,
2997 iter_dns_store(qstate->env, &iq->response->qinfo,
2998 iq->response->rep, 1, qstate->prefetch_leeway,
2999 iq->dp&&iq->dp->has_parent_side_NS, NULL,
3002 iq->qchase.qname = sname;
3003 iq->qchase.qname_len = snamelen;
3005 iq->deleg_msg = NULL;
3006 iq->dp = NULL;
3007 iq->dsns_point = NULL;
3008 iq->auth_zone_response = 0;
3009 iq->sent_count = 0;
3010 iq->dp_target_count = 0;
3011 if(iq->minimisation_state != MINIMISE_STATE)
3014 iq->query_restart_count++;
3016 iq->minimisation_state = INIT_MINIMISE_STATE;
3022 outbound_list_clear(&iq->outlist);
3023 iq->num_current_queries = 0;
3027 iq->num_target_queries = 0;
3034 return next_state(iq, INIT_REQUEST_STATE);
3039 if(!dname_subdomain_c(iq->qchase.qname, iq->dp->name)) {
3047 iq->dp->name, iq->dp->namelen,
3049 iq->qchase.qtype))
3056 if(!dname_subdomain_c(iq->qchase.qname, iq->dp->name)) {
3065 iq->dp->name, iq->dp->namelen,
3066 *qstate->env->now, 0, 1, iq->qchase.qtype))
3085 iq->minimisation_state = DONOT_MINIMISE_STATE;
3086 if(iq->auth_zone_response) {
3088 iq->auth_zone_response = 0;
3090 iq->dp->name, iq->dp->namelen, qstate->qinfo.qclass)) {
3094 "for auth zone", iq->dp->name);
3099 iq->auth_zone_avoid = 1;
3100 if(iq->dp->auth_dp) {
3103 iq->dp = NULL;
3104 return next_state(iq, INIT_REQUEST_STATE);
3107 return next_state(iq, QUERYTARGETS_STATE);
3175 struct iter_qstate* iq = (struct iter_qstate*)qstate->minfo[id];
3177 iq->response->rep->flags &= ~(BIT_RD|BIT_RA); /* ignore rec-lame */
3179 (int)((iq->chase_flags&BIT_RD) || iq->chase_to_rd),
3180 iq->response, &iq->qchase, iq->dp);
3183 qstate->return_msg = iq->response;
3202 qstate->qinfo.qclass, qstate, id, iq,
3206 generate_a_aaaa_check(qstate, iq, id);
3232 struct iter_qstate* iq = (struct iter_qstate*)qstate->minfo[id];
3261 /* if iq->query_for_pside_glue then add the pside_glue (marked lame) */
3262 if(iq->pside_glue) {
3267 iq->pside_glue);
3269 iq->pside_glue, 1, NULL))
3278 rrset = reply_find_answer_rrset(&iq->qchase, qstate->return_msg->rep);
3326 /* if the finished (iq->response) query has no NS set: continue
3464 struct iter_qstate* iq = (struct iter_qstate*)qstate->minfo[id];
3470 if(iq->qchase.qclass == 0) {
3472 iq->qchase.qclass = LDNS_RR_CLASS_ANY;
3480 c, qstate, id, iq, INIT_REQUEST_STATE,
3489 iq->num_current_queries ++;
3495 if(iq->num_current_queries == 0) {
3511 * @param iq: iterator query state.
3517 processFinished(struct module_qstate* qstate, struct iter_qstate* iq,
3524 if(!qstate->no_cache_store && iq->query_for_pside_glue
3525 && !iq->pside_glue)
3527 iq->deleg_msg?iq->deleg_msg->rep:
3528 (iq->response?iq->response->rep:NULL));
3529 if(!iq->response) {
3537 iq->response->rep->flags |= BIT_RA;
3541 iq->response->rep->flags &= ~BIT_AA;
3544 iq->response->rep->flags |= BIT_QR;
3553 if(iq->an_prepend_list || iq->ns_prepend_list) {
3554 if(!iter_prepend(iq, iq->response, qstate->region)) {
3559 iq->response->qinfo = qstate->qinfo;
3561 iq->response->rep->security = sec_status_unchecked;
3567 iq->response->rep, 0, qstate->prefetch_leeway,
3568 iq->dp&&iq->dp->has_parent_side_NS,
3573 qstate->return_msg = iq->response;
3612 * @param iq: iterator query state.
3616 iter_handle(struct module_qstate* qstate, struct iter_qstate* iq,
3622 iter_state_to_string(iq->state));
3623 switch(iq->state) {
3625 cont = processInitRequest(qstate, iq, ie, id);
3628 cont = processInitRequest2(qstate, iq, id);
3631 cont = processInitRequest3(qstate, iq, id);
3634 cont = processQueryTargets(qstate, iq, ie, id);
3637 cont = processQueryResponse(qstate, iq, id);
3646 cont = processDSNSFind(qstate, iq, id);
3649 cont = processFinished(qstate, iq, id);
3653 iq->state);
3665 * @param iq: iterator query state.
3669 process_request(struct module_qstate* qstate, struct iter_qstate* iq,
3674 iq->state = INIT_REQUEST_STATE;
3675 iq->final_state = FINISHED_STATE;
3677 iter_handle(qstate, iq, ie, id);
3682 process_response(struct module_qstate* qstate, struct iter_qstate* iq,
3691 iq->response = NULL;
3692 iq->state = QUERY_RESP_STATE;
3694 if(event == module_event_noreply && iq->timeout_count >= 3 &&
3696 !iq->caps_fallback && !is_caps_whitelisted(ie, iq)) {
3698 iq->caps_fallback = 1;
3699 iq->caps_server = 0;
3700 iq->caps_reply = NULL;
3701 iq->caps_response = NULL;
3702 iq->caps_minimisation_state = DONOT_MINIMISE_STATE;
3703 iq->state = QUERYTARGETS_STATE;
3704 iq->num_current_queries--;
3707 iter_dec_attempts(iq->dp, 3);
3716 outbound_list_remove(&iq->outlist, outbound);
3762 if(!scrub_message(pkt, prs, &iq->qinfo_out, iq->dp->name,
3765 if(event == module_event_capsfail && !iq->caps_fallback) {
3766 iq->caps_fallback = 1;
3767 iq->caps_server = 0;
3768 iq->caps_reply = NULL;
3769 iq->caps_response = NULL;
3770 iq->caps_minimisation_state = DONOT_MINIMISE_STATE;
3771 iq->state = QUERYTARGETS_STATE;
3772 iq->num_current_queries--;
3779 iq->response = dns_alloc_msg(pkt, prs, qstate->region);
3780 if(!iq->response)
3783 log_name_addr(VERB_DETAIL, "reply from", iq->dp->name,
3786 log_dns_msg("incoming scrubbed packet:", &iq->response->qinfo,
3787 iq->response->rep);
3789 if(event == module_event_capsfail || iq->caps_fallback) {
3791 iq->minimisation_state != DONOT_MINIMISE_STATE) {
3794 iq->minimisation_state = SKIP_MINIMISE_STATE;
3798 caps_strip_reply(iq->response->rep);
3800 if(iq->caps_fallback &&
3801 iq->caps_minimisation_state != iq->minimisation_state) {
3804 iq->caps_fallback = 0;
3807 if(!iq->caps_fallback) {
3809 iq->caps_fallback = 1;
3810 iq->caps_server = 0;
3811 iq->caps_reply = iq->response->rep;
3812 iq->caps_response = iq->response;
3813 iq->caps_minimisation_state = iq->minimisation_state;
3814 iq->state = QUERYTARGETS_STATE;
3815 iq->num_current_queries--;
3820 if(!iq->caps_reply) {
3821 iq->caps_reply = iq->response->rep;
3822 iq->caps_response = iq->response;
3823 iq->caps_server = -1; /*become zero at ++,
3825 } else if(caps_failed_rcode(iq->caps_reply) &&
3826 !caps_failed_rcode(iq->response->rep)) {
3828 iq->caps_reply = iq->response->rep;
3829 iq->caps_response = iq->response;
3830 } else if(!caps_failed_rcode(iq->caps_reply) &&
3831 caps_failed_rcode(iq->response->rep)) {
3836 } else if(caps_failed_rcode(iq->caps_reply) &&
3837 caps_failed_rcode(iq->response->rep)) {
3840 } else if(!reply_equal(iq->response->rep, iq->caps_reply,
3844 outbound_list_remove(&iq->outlist, outbound);
3851 iq->caps_server++;
3852 iq->state = QUERYTARGETS_STATE;
3853 iq->num_current_queries--;
3859 iq->caps_fallback = 0; /* if we were in fallback, 0x20 is OK now */
3862 outbound_list_remove(&iq->outlist, outbound);
3863 iter_handle(qstate, iq, ie, id);
3871 struct iter_qstate* iq = (struct iter_qstate*)qstate->minfo[id];
3874 if(iq) log_query_info(VERB_QUERY, "iterator operate: query",
3876 if(iq && qstate->qinfo.qname != iq->qchase.qname)
3878 &iq->qchase);
3882 iq == NULL) {
3888 iq = (struct iter_qstate*)qstate->minfo[id];
3889 process_request(qstate, iq, ie, id);
3892 if(iq && event == module_event_pass) {
3893 iter_handle(qstate, iq, ie, id);
3896 if(iq && outbound) {
3897 process_response(qstate, iq, ie, id, outbound, event);
3915 struct iter_qstate* iq;
3918 iq = (struct iter_qstate*)qstate->minfo[id];
3919 if(iq) {
3920 outbound_list_clear(&iq->outlist);
3921 if(iq->target_count && --iq->target_count[0] == 0)
3922 free(iq->target_count);
3923 iq->num_current_queries = 0;