]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
prevent a possible shutdown hang in rndc
authorEvan Hunt <each@isc.org>
Tue, 6 Sep 2022 21:13:23 +0000 (14:13 -0700)
committerEvan Hunt <each@isc.org>
Mon, 12 Sep 2022 20:14:19 +0000 (13:14 -0700)
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.)

bin/rndc/rndc.c

index cabeb91e055832da612d7b3b7ebeaf441e00b1f8..ff7b9e8e5513b42de9cbb522a6a87ed6c2d42a67 100644 (file)
@@ -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);