]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
On shutdown, return ISC_R_SHUTTINGDOWN from isc_taskmgr_excltask()
authorOndřej Surý <ondrej@isc.org>
Wed, 5 Jan 2022 10:48:22 +0000 (11:48 +0100)
committerOndřej Surý <ondrej@isc.org>
Wed, 5 Jan 2022 12:41:12 +0000 (13:41 +0100)
The isc_taskmgr_excltask() would return ISC_R_NOTFOUND either when the
exclusive task was not set (yet) or when the taskmgr is shutting down
and the exclusive task has been already cleared.

Distinguish between the two states and return ISC_R_SHUTTINGDOWN when
the taskmgr is being shut down instead of ISC_R_NOTFOUND.

lib/isc/task.c

index 2cfe953b339b2f1243b88be3ae2df48825655a9d..cf22e91d53bade2d8141d20fe015aea03360a088 100644 (file)
@@ -1084,7 +1084,7 @@ isc_taskmgr_setexcltask(isc_taskmgr_t *mgr, isc_task_t *task) {
 
 isc_result_t
 isc_taskmgr_excltask(isc_taskmgr_t *mgr, isc_task_t **taskp) {
-       isc_result_t result = ISC_R_SUCCESS;
+       isc_result_t result;
 
        REQUIRE(VALID_MANAGER(mgr));
        REQUIRE(taskp != NULL && *taskp == NULL);
@@ -1092,6 +1092,9 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr, isc_task_t **taskp) {
        LOCK(&mgr->excl_lock);
        if (mgr->excl != NULL) {
                isc_task_attach(mgr->excl, taskp);
+               result = ISC_R_SUCCESS;
+       } else if (atomic_load_relaxed(&mgr->exiting)) {
+               result = ISC_R_SHUTTINGDOWN;
        } else {
                result = ISC_R_NOTFOUND;
        }