From: Evan Hunt Date: Tue, 6 Sep 2022 21:13:23 +0000 (-0700) Subject: prevent a possible shutdown hang in rndc X-Git-Tag: v9.19.6~68^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9683439d7399e1e525853c42f7cc337b3081405e;p=thirdparty%2Fbind9.git prevent a possible shutdown hang in rndc In rndc_recvdone(), if 'sends' was not 0, then 'recvs' was not decremented, in which case isc_loopmgr_shutdown() was never reached, which could cause a hang. (This has not been observed to happen, but the code was incorrect on examination.) --- diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index cabeb91e055..ff7b9e8e551 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -390,8 +390,8 @@ rndc_recvdone(isc_nmhandle_t *handle, isc_result_t result, void *arg) { REQUIRE(recvdone_handle == handle); isc_nmhandle_detach(&recvdone_handle); - if (atomic_load_acquire(&sends) == 0 && - atomic_fetch_sub_release(&recvs, 1) == 1) + if (atomic_fetch_sub_release(&recvs, 1) == 1 && + atomic_load_acquire(&sends) == 0) { shuttingdown = true; isc_task_detach(&rndc_task);