2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

Emit a ISC_R_CANCELED result instead of ISC_R_SHUTTINGDOWN

When request manager shuts down, it also shuts down all its ongoing
requests. Currently it calls their callback functions with a
ISC_R_SHUTTINGDOWN result code for the request. Since a request
manager can shutdown not only during named shutdown but also during
named reconfiguration, instead of sending ISC_R_SHUTTINGDOWN result
code send a ISC_R_CANCELED code to avoid confusion and errors with
the expectation that a ISC_R_SHUTTINGDOWN result code can only be
received during actual shutdown of named.

All the callback functions which are passed to either the
dns_request_create() or the dns_request_createraw() functions have
been analyzed to confirm that they can process both the
ISC_R_SHUTTINGDOWN and ISC_R_CANCELED result codes. Changes were
made where it was necessary.

(cherry picked from commit f4cd307c6b)
This commit is contained in:
Aram Sargsyan
2025-05-21 15:27:53 +00:00
committed by Ondřej Surý
parent 20eb80333e
commit fa974811a9
3 changed files with 8 additions and 6 deletions

View File

@@ -763,7 +763,7 @@ sleep 1
# Reconfigure named while zone transfer attempt is in progress. # Reconfigure named while zone transfer attempt is in progress.
$RNDCCMD 10.53.0.6 reconfig 2>&1 | sed 's/^/ns6 /' | cat_i $RNDCCMD 10.53.0.6 reconfig 2>&1 | sed 's/^/ns6 /' | cat_i
# Confirm that the ongoing SOA request was canceled, caused by the reconfiguratoin. # Confirm that the ongoing SOA request was canceled, caused by the reconfiguratoin.
retry_quiet 60 wait_for_message "refresh: request result: shutting down" || tmp=1 retry_quiet 60 wait_for_message "refresh: request result: operation canceled" || tmp=1
if test $tmp != 0; then echo_i "failed"; fi if test $tmp != 0; then echo_i "failed"; fi
status=$((status + tmp)) status=$((status + tmp))

View File

@@ -143,7 +143,7 @@ dns_requestmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
for (size_t i = 0; i < nloops; i++) { for (size_t i = 0; i < nloops; i++) {
ISC_LIST_INIT(requestmgr->requests[i]); ISC_LIST_INIT(requestmgr->requests[i]);
/* unreferenced in requests_shutdown() */ /* unreferenced in requests_cancel() */
isc_loop_ref(isc_loop_get(requestmgr->loopmgr, i)); isc_loop_ref(isc_loop_get(requestmgr->loopmgr, i));
} }
@@ -169,7 +169,7 @@ dns_requestmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
} }
static void static void
requests_shutdown(void *arg) { requests_cancel(void *arg) {
dns_requestmgr_t *requestmgr = arg; dns_requestmgr_t *requestmgr = arg;
dns_request_t *request = NULL, *next = NULL; dns_request_t *request = NULL, *next = NULL;
uint32_t tid = isc_tid(); uint32_t tid = isc_tid();
@@ -181,7 +181,7 @@ requests_shutdown(void *arg) {
/* The callback has been already scheduled */ /* The callback has been already scheduled */
continue; continue;
} }
req_sendevent(request, ISC_R_SHUTTINGDOWN); req_sendevent(request, ISC_R_CANCELED);
} }
isc_loop_unref(isc_loop_get(requestmgr->loopmgr, tid)); isc_loop_unref(isc_loop_get(requestmgr->loopmgr, tid));
@@ -217,12 +217,12 @@ dns_requestmgr_shutdown(dns_requestmgr_t *requestmgr) {
if (i == tid) { if (i == tid) {
/* Run the current loop synchronously */ /* Run the current loop synchronously */
requests_shutdown(requestmgr); requests_cancel(requestmgr);
continue; continue;
} }
isc_loop_t *loop = isc_loop_get(requestmgr->loopmgr, i); isc_loop_t *loop = isc_loop_get(requestmgr->loopmgr, i);
isc_async_run(loop, requests_shutdown, requestmgr); isc_async_run(loop, requests_cancel, requestmgr);
} }
} }

View File

@@ -13609,6 +13609,7 @@ stub_callback(void *arg) {
case ISC_R_SUCCESS: case ISC_R_SUCCESS:
break; break;
case ISC_R_SHUTTINGDOWN: case ISC_R_SHUTTINGDOWN:
case ISC_R_CANCELED:
goto exiting; goto exiting;
case ISC_R_TIMEDOUT: case ISC_R_TIMEDOUT:
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOEDNS)) { if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOEDNS)) {
@@ -13953,6 +13954,7 @@ refresh_callback(void *arg) {
case ISC_R_SUCCESS: case ISC_R_SUCCESS:
break; break;
case ISC_R_SHUTTINGDOWN: case ISC_R_SHUTTINGDOWN:
case ISC_R_CANCELED:
goto exiting; goto exiting;
case ISC_R_TIMEDOUT: case ISC_R_TIMEDOUT:
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOEDNS)) { if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOEDNS)) {