From 6a50a5b6dcc110d2ba32d88645162b33f38437e5 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Thu, 14 Jan 1999 20:03:54 +0000 Subject: [PATCH] per task mctx --- lib/isc/include/isc/task.h | 4 +++- lib/isc/task.c | 25 ++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/isc/include/isc/task.h b/lib/isc/include/isc/task.h index b11e3cb389..b1f4868444 100644 --- a/lib/isc/include/isc/task.h +++ b/lib/isc/include/isc/task.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998 Internet Software Consortium. + * Copyright (C) 1998, 1999 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -83,11 +83,13 @@ void isc_event_free(isc_event_t **); ***/ isc_result_t isc_task_create(isc_taskmgr_t *, + isc_mem_t *, unsigned int, isc_task_t **); void isc_task_attach(isc_task_t *, isc_task_t **); void isc_task_detach(isc_task_t **); +isc_mem_t * isc_task_mem(isc_task_t *); isc_result_t isc_task_send(isc_task_t *, isc_event_t **); unsigned int isc_task_purge(isc_task_t *, void *, diff --git a/lib/isc/task.c b/lib/isc/task.c index b35da3cce5..faf4c7d82c 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998 Internet Software Consortium. + * Copyright (C) 1998, 1999 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -53,6 +53,7 @@ struct isc_task { unsigned int magic; isc_taskmgr_t * manager; isc_mutex_t lock; + isc_mem_t * mctx; /* Locked by task lock. */ task_state_t state; unsigned int references; @@ -173,7 +174,7 @@ task_free(isc_task_t *task) { } isc_result_t -isc_task_create(isc_taskmgr_t *manager, unsigned int quantum, +isc_task_create(isc_taskmgr_t *manager, isc_mem_t *mctx, unsigned int quantum, isc_task_t **taskp) { isc_task_t *task; @@ -181,13 +182,15 @@ isc_task_create(isc_taskmgr_t *manager, unsigned int quantum, REQUIRE(VALID_MANAGER(manager)); REQUIRE(taskp != NULL && *taskp == NULL); - task = isc_mem_get(manager->mctx, sizeof *task); + if (mctx == NULL) + mctx = manager->mctx; + task = isc_mem_get(mctx, sizeof *task); if (task == NULL) return (ISC_R_NOMEMORY); - task->manager = manager; + task->mctx = mctx; if (isc_mutex_init(&task->lock) != ISC_R_SUCCESS) { - isc_mem_put(manager->mctx, task, sizeof *task); + isc_mem_put(mctx, task, sizeof *task); UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_mutex_init() failed"); return (ISC_R_UNEXPECTED); @@ -251,6 +254,14 @@ isc_task_detach(isc_task_t **taskp) { *taskp = NULL; } +isc_mem_t * +isc_task_mem(isc_task_t *task) { + + REQUIRE(VALID_TASK(task)); + + return (task->mctx); +} + isc_result_t isc_task_send(isc_task_t *task, isc_event_t **eventp) { isc_boolean_t was_idle = ISC_FALSE; @@ -406,7 +417,7 @@ isc_task_onshutdown(isc_task_t *task, isc_taskaction_t action, void *arg) { REQUIRE(VALID_TASK(task)); - event = event_allocate(task->manager->mctx, + event = event_allocate(task->mctx, NULL, ISC_TASKEVENT_SHUTDOWN, action, @@ -427,7 +438,7 @@ isc_task_onshutdown(isc_task_t *task, isc_taskaction_t action, void *arg) { UNLOCK(&task->lock); if (disallowed) - isc_mem_put(task->manager->mctx, event, sizeof *event); + isc_mem_put(task->mctx, event, sizeof *event); return (result); }