From e09b36f2ccad77d78cba6435a26b49884a8dcdea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Tue, 14 Jun 2022 13:13:32 +0200 Subject: [PATCH] Adjust recursion quota when starting a fetch fails Some functions fail to detach from the recursion quota if an error occurs while initiating recursion. This causes the recursive client counter to be off. Add missing recursionquota_detach() calls, reworking cleanup code where appropriate. --- lib/ns/query.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ns/query.c b/lib/ns/query.c index f1f004a684..529e8b03f3 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -2618,6 +2618,7 @@ fetch_and_forget(ns_client_t *client, dns_name_t *qname, dns_rdatatype_t qtype, if (result != ISC_R_SUCCESS) { ns_client_putrdataset(client, &tmprdataset); isc_nmhandle_detach(handlep); + recursionquotatype_detach(client, recursion_type); } } @@ -6464,6 +6465,7 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname, if (sigrdataset != NULL) { ns_client_putrdataset(client, &sigrdataset); } + recursionquotatype_detach(client, RECTYPE_NORMAL); } /* @@ -6833,7 +6835,7 @@ ns_query_hookasync(query_ctx_t *qctx, ns_query_starthookasync_t runasync, client->manager->task, query_hookresume, client, &client->query.hookactx); if (result != ISC_R_SUCCESS) { - goto cleanup; + goto cleanup_and_detach_from_quota; } /* @@ -6850,6 +6852,8 @@ ns_query_hookasync(query_ctx_t *qctx, ns_query_starthookasync_t runasync, isc_nmhandle_attach(client->handle, &HANDLE_RECTYPE_HOOK(client)); return (ISC_R_SUCCESS); +cleanup_and_detach_from_quota: + recursionquotatype_detach(client, RECTYPE_HOOK); cleanup: /* * If we fail, send SERVFAIL now. It may be better to let the caller