Commit e0d8e807 authored by Bob Halley's avatar Bob Halley

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

parent bab662ff
......@@ -76,7 +76,7 @@ isc_result_t
isc_task_create(isc_taskmgr_t *manager, isc_mem_t *mctx,
unsigned int quantum, isc_task_t **taskp);
/*
* Create a task running.
* Create a task.
*
* Notes:
*
......@@ -106,6 +106,7 @@ isc_task_create(isc_taskmgr_t *manager, isc_mem_t *mctx,
* ISC_R_SUCCESS
* ISC_R_NOMEMORY
* ISC_R_UNEXPECTED
* ISC_R_SHUTTINGDOWN
*/
void
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment