UNUSED(func);
#endif
- LOCK(&fctx->lock);
+ if (result != ISC_R_SUCCESS) {
+ LOCK(&fctx->lock);
+ }
/* We need to do this under the lock for intra-thread synchronization */
if (fctx->state == fetchstate_done) {
UNLOCK(&fctx->lock);
}
}
}
-
UNLOCK(&fctx->lock);
- dns_adb_destroyfind(&find);
-
if (want_done) {
FCTXTRACE("fetch failed in finddone(); return "
"ISC_R_FAILURE");
fctx_try(fctx, true);
}
+ dns_adb_destroyfind(&find);
+
fetchctx_detach(&fctx);
}
dns_rdataset_t sigrdataset;
dns_db_t *db = NULL;
dns_dbnode_t *node = NULL;
- bool fixup_result = false;
REQUIRE(VALID_FCTX(fctx));
dns_db_attachnode(node, &resp->node);
}
dns_name_copy(fname, resp->foundname);
+ clone_results(fctx);
if (result == DNS_R_CNAME &&
dns_rdataset_isassociated(&rdataset) &&
fctx->type == dns_rdatatype_cname)
{
- fixup_result = true;
+ fctx_success_unref(fctx);
+ result = ISC_R_SUCCESS;
+ } else {
+ UNLOCK(&fctx->lock);
}
- clone_results(fctx);
- UNLOCK(&fctx->lock);
goto cleanup;
}
UNLOCK(&fctx->lock);
}
if (result != ISC_R_SUCCESS) {
/* An error occurred, tear down whole fctx */
- fctx_failure_unref(fctx, fixup_result ? ISC_R_SUCCESS : result);
+ fctx_failure_unref(fctx, result);
}
fetchctx_detach(&fctx);
}
done = true;
cleanup:
- UNLOCK(&fctx->lock);
-cleanup_unlocked:
+ if (!done || result != ISC_R_SUCCESS) {
+ UNLOCK(&fctx->lock);
+ }
+
+ if (done) {
+ if (result == ISC_R_SUCCESS) {
+ fctx_success_unref(fctx);
+ } else {
+ fctx_failure_unref(fctx, result);
+ }
+ }
+cleanup_unlocked:
if (node != NULL) {
dns_db_detachnode(&node);
}
dns_validator_send(nextval);
}
- if (done && result == ISC_R_SUCCESS) {
- fctx_success_unref(fctx);
- } else if (done) {
- fctx_failure_unref(fctx, result);
- }
-
/*
* val->name points to name on a message on one of the
* queries on the fetch context so the name has to be
dns_validator_shutdown(val);
dns_validator_detach(&val);
fetchctx_detach(&fctx);
- INSIST(node == NULL);
}
static void
rctx->next_server = false;
rctx->resend = false;
}
- UNLOCK(&fctx->lock);
if (rctx->next_server) {
+ UNLOCK(&fctx->lock);
rctx_nextserver(rctx, message, addrinfo, result);
} else if (rctx->resend) {
+ UNLOCK(&fctx->lock);
rctx_resend(rctx, addrinfo);
} else if (result == DNS_R_CHASEDSSERVERS) {
+ UNLOCK(&fctx->lock);
rctx_chaseds(rctx, message, addrinfo, result);
} else if (result == ISC_R_SUCCESS && !HAVE_ANSWER(fctx)) {
+ UNLOCK(&fctx->lock);
/*
* All has gone well so far, but we are waiting for the DNSSEC
* validator to validate the answer.
FCTXTRACE("wait for validator");
fctx_cancelqueries(fctx, true, false);
} else if (result == ISC_R_SUCCESS) {
- /* We are done. */
+ /* Ended successfully. */
fctx_success_detach(&rctx->fctx);
} else {
- /* Done with an error. */
+ UNLOCK(&fctx->lock);
+ /* Ended with failure. */
fctx_failure_detach(&rctx->fctx, result);
}