From 8fb5bc783f836eff2cb90e5356aad059c1d66c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 23 Oct 2018 09:39:56 +0000 Subject: [PATCH] Comment about taskmgr exclusive mode, fix a REQUIRE. --- lib/isc/task.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/isc/task.c b/lib/isc/task.c index 2d01c9288c..87ece27ec0 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -1015,6 +1015,16 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) { XTHREADTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TASK, ISC_MSG_WORKING, "halting")); + /* + * Switching to exclusive mode is done as a 2-phase-lock, + * checking if we have to switch is done without any locks + * on pause_requested and exclusive_requested to save time - + * the worst thing that can happen is that we'll launch one task + * more and exclusive task will be postponed a bit. + * + * Broadcasting on halt_cond seems suboptimal, but exclusive tasks + * are rare enought that we don't care. + */ LOCK(&manager->halt_lock); manager->halted++; BROADCAST(&manager->halt_cond); @@ -1532,11 +1542,8 @@ isc_task_beginexclusive(isc_task_t *task0) { REQUIRE(VALID_TASK(task)); REQUIRE(task->state == task_state_running); - -/* - * TODO REQUIRE(task == task->manager->excl); - * it should be here, it fails on shutdown server->task - */ + REQUIRE(task == task->manager->excl || + (task->manager->exiting && task->manager->excl == NULL)); if (manager->exclusive_requested || manager->pause_requested) { return (ISC_R_LOCKBUSY);