findnoqname(fetchctx_t *fctx, dns_message_t *message, dns_name_t *name,
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
-#define fctx_done_detach(fctxp, result) \
+#define fctx_failure_detach(fctxp, result) \
+ REQUIRE(result != ISC_R_SUCCESS); \
if (fctx__done(*fctxp, result, __func__, __FILE__, __LINE__)) { \
fetchctx_detach(fctxp); \
}
-#define fctx_done_unref(fctx, result) \
+#define fctx_failure_unref(fctx, result) \
+ REQUIRE(result != ISC_R_SUCCESS); \
if (fctx__done(fctx, result, __func__, __FILE__, __LINE__)) { \
fetchctx_unref(fctx); \
}
+#define fctx_success_detach(fctxp) \
+ if (fctx__done(*fctxp, ISC_R_SUCCESS, __func__, __FILE__, __LINE__)) { \
+ fetchctx_detach(fctxp); \
+ }
+
+#define fctx_success_unref(fctx) \
+ if (fctx__done(fctx, ISC_R_SUCCESS, __func__, __FILE__, __LINE__)) { \
+ fetchctx_unref(fctx); \
+ }
+
#if DNS_RESOLVER_TRACE
#define fetchctx_ref(ptr) fetchctx__ref(ptr, __func__, __FILE__, __LINE__)
#define fetchctx_unref(ptr) fetchctx__unref(ptr, __func__, __FILE__, __LINE__)
"due to unexpected result; responding",
eresult);
fctx_cancelquery(©, NULL, false, false);
- fctx_done_detach(&fctx, eresult);
+ fctx_failure_detach(&fctx, eresult);
break;
}
"responding");
fctx_cancelquery(©, NULL, false, false);
- fctx_done_detach(&fctx, result);
+ fctx_failure_detach(&fctx, result);
break;
}
case ISC_R_SHUTTINGDOWN:
FCTXTRACE3("shutdown in resquery_connected()", eresult);
fctx_cancelquery(©, NULL, true, false);
- fctx_done_detach(&fctx, eresult);
+ fctx_failure_detach(&fctx, eresult);
break;
case ISC_R_HOSTDOWN:
eresult);
fctx_cancelquery(©, NULL, false, false);
- fctx_done_detach(&fctx, eresult);
+ fctx_failure_detach(&fctx, eresult);
break;
}
FCTXTRACE("fetch failed in finddone(); return "
"ISC_R_FAILURE");
- fctx_done_unref(fctx, ISC_R_FAILURE);
+ fctx_failure_unref(fctx, ISC_R_FAILURE);
} else if (want_try) {
fctx_try(fctx, true);
}
done:
if (result != ISC_R_SUCCESS) {
- fctx_done_detach(&fctx, result);
+ fctx_failure_detach(&fctx, result);
}
}
}
if (result != ISC_R_SUCCESS) {
/* An error occurred, tear down whole fctx */
- fctx_done_unref(fctx, fixup_result ? ISC_R_SUCCESS : result);
+ fctx_failure_unref(fctx, fixup_result ? ISC_R_SUCCESS : result);
}
fetchctx_detach(&fctx);
}
dns_ede_add(&fctx->edectx, DNS_EDE_NOREACHABLEAUTH, NULL);
- fctx_done_detach(&fctx, DNS_R_SERVFAIL);
+ fctx_failure_detach(&fctx, DNS_R_SERVFAIL);
}
static void
REQUIRE(VALID_FCTX(fctx));
- fctx_done_unref(fctx, ISC_R_SHUTTINGDOWN);
+ fctx_failure_unref(fctx, ISC_R_SHUTTINGDOWN);
fetchctx_detach(&fctx);
}
dns_validator_send(nextval);
}
- if (done) {
- fctx_done_unref(fctx, result);
+ if (done && result == ISC_R_SUCCESS) {
+ fctx_success_unref(fctx);
+ } else if (done) {
+ fctx_failure_unref(fctx, result);
}
/*
if (result != ISC_R_SUCCESS) {
/* An error occurred, tear down whole fctx */
- fctx_done_unref(fctx, result);
+ fctx_failure_unref(fctx, result);
}
fetchctx_detach(&fctx);
dcname = dns_fixedname_initname(&founddc);
if (result != ISC_R_SUCCESS) {
- fctx_done_detach(&rctx->fctx, DNS_R_SERVFAIL);
+ fctx_failure_detach(&rctx->fctx, DNS_R_SERVFAIL);
return;
}
if (dns_rdatatype_atparent(fctx->type)) {
findoptions, true, true, &fctx->nameservers, NULL);
if (result != ISC_R_SUCCESS) {
FCTXTRACE("couldn't find a zonecut");
- fctx_done_detach(&rctx->fctx, DNS_R_SERVFAIL);
+ fctx_failure_detach(&rctx->fctx, DNS_R_SERVFAIL);
return;
}
if (!dns_name_issubdomain(fname, fctx->domain)) {
* QDOMAIN.
*/
FCTXTRACE("nameservers now above QDOMAIN");
- fctx_done_detach(&rctx->fctx, DNS_R_SERVFAIL);
+ fctx_failure_detach(&rctx->fctx, DNS_R_SERVFAIL);
return;
}
result = fcount_incr(fctx, true);
if (result != ISC_R_SUCCESS) {
- fctx_done_detach(&rctx->fctx, DNS_R_SERVFAIL);
+ fctx_failure_detach(&rctx->fctx, DNS_R_SERVFAIL);
return;
}
fctx->ns_ttl = fctx->nameservers.ttl;
inc_stats(fctx->res, dns_resstatscounter_retry);
result = fctx_query(fctx, addrinfo, rctx->retryopts);
if (result != ISC_R_SUCCESS) {
- fctx_done_detach(&rctx->fctx, result);
+ fctx_failure_detach(&rctx->fctx, result);
}
}
if (result == DNS_R_DUPLICATE) {
result = DNS_R_SERVFAIL;
}
- fctx_done_detach(&rctx->fctx, result);
+ fctx_failure_detach(&rctx->fctx, result);
fetchctx_detach(&fctx);
return;
}
{
fctx_cancelquery(&query, rctx->finish, rctx->no_response,
false);
- fctx_done_detach(&rctx->fctx, DNS_R_SERVFAIL);
+ fctx_failure_detach(&rctx->fctx, DNS_R_SERVFAIL);
goto detach;
}
#endif /* ifdef ENABLE_AFL */
*/
FCTXTRACE("wait for validator");
fctx_cancelqueries(fctx, true, false);
+ } else if (result == ISC_R_SUCCESS) {
+ /* We are done. */
+ fctx_success_detach(&rctx->fctx);
} else {
- /*
- * We're done.
- */
- fctx_done_detach(&rctx->fctx, result);
+ /* Done with an error. */
+ fctx_failure_detach(&rctx->fctx, result);
}
detach: