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.
(cherry picked from commit
f9d90159b84831fd83d74594827fedf0f4e9e265)
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);
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;
}