2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

If creating a task and the manager is exiting, return ISC_R_SHUTTINGDOWN

This commit is contained in:
Bob Halley
2000-01-17 23:41:33 +00:00
parent bab662ff0c
commit e0d8e8073f
2 changed files with 16 additions and 5 deletions

View File

@@ -145,6 +145,7 @@ isc_task_create(isc_taskmgr_t *manager, isc_mem_t *mctx, unsigned int quantum,
isc_task_t **taskp)
{
isc_task_t *task;
isc_boolean_t exiting;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(taskp != NULL && *taskp == NULL);
@@ -172,13 +173,22 @@ isc_task_create(isc_taskmgr_t *manager, isc_mem_t *mctx, unsigned int quantum,
INIT_LINK(task, link);
INIT_LINK(task, ready_link);
exiting = ISC_FALSE;
LOCK(&manager->lock);
/* XXX Should disallow if task manager is exiting. */
if (task->quantum == 0)
task->quantum = manager->default_quantum;
APPEND(manager->tasks, task, link);
if (!manager->exiting) {
if (task->quantum == 0)
task->quantum = manager->default_quantum;
APPEND(manager->tasks, task, link);
} else
exiting = ISC_TRUE;
UNLOCK(&manager->lock);
if (exiting) {
isc_mutex_destroy(&task->lock);
isc_mem_put(mctx, task, sizeof *task);
return (ISC_R_SHUTTINGDOWN);
}
task->magic = TASK_MAGIC;
*taskp = task;