From 2215fe02f1c7f2349554dce1423f50b528b96d3b Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sat, 18 Mar 2000 00:33:15 +0000 Subject: [PATCH] Require a taskmgr and socketmgr for omapi_lib_init. Create an omapi_task in omapi_lib_init and destroy it in omapi_lib_destroy. --- lib/omapi/lib.c | 58 ++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/lib/omapi/lib.c b/lib/omapi/lib.c index 8f228b9d86..73176ce3c4 100644 --- a/lib/omapi/lib.c +++ b/lib/omapi/lib.c @@ -41,11 +41,10 @@ omapi_objecttype_t *omapi_type_message; omapi_objecttype_t *omapi_object_types; isc_mem_t *omapi_mctx; +isc_task_t *omapi_task; isc_taskmgr_t *omapi_taskmgr; isc_socketmgr_t *omapi_socketmgr; -isc_boolean_t omapi_internal_mctx = ISC_FALSE; - /*** *** Private to lib.c. ***/ @@ -72,7 +71,9 @@ omapi_lib_initmsgcat(void) { } isc_result_t -omapi_lib_init(isc_mem_t *mctx) { +omapi_lib_init(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, + isc_socketmgr_t *socketmgr) +{ isc_result_t result; /* @@ -81,35 +82,23 @@ omapi_lib_init(isc_mem_t *mctx) { REQUIRE(omapi_mctx == NULL && omapi_socketmgr == NULL && omapi_taskmgr == NULL && + omapi_task == NULL && omapi_object_types == NULL); - if (mctx != NULL) - omapi_mctx = mctx; + REQUIRE(mctx != NULL && taskmgr != NULL && socketmgr != NULL); - else { - omapi_internal_mctx = ISC_TRUE; - result = isc_mem_create(0, 0, &omapi_mctx); - if (result != ISC_R_SUCCESS) - return (result); - } + omapi_mctx = mctx; + omapi_taskmgr = taskmgr; + omapi_socketmgr = socketmgr; - result = isc_socketmgr_create(omapi_mctx, &omapi_socketmgr); - if (result != ISC_R_SUCCESS) - return (result); - - /* - * XXXDCL should the caller specify an existing taskmgr instead? - * how about having the caller specify an existing task? - * i need clarity on how taskmgr/task/event all work together. - */ - result = isc_taskmgr_create(omapi_mctx, 1, 0, &omapi_taskmgr); - if (result != ISC_R_SUCCESS) - return (result); + result = isc_task_create(omapi_taskmgr, omapi_mctx, 0, &omapi_task); /* * Initialize the standard object types. */ - result = generic_init(); + if (result == ISC_R_SUCCESS) + result = generic_init(); + if (result == ISC_R_SUCCESS) result = listener_init(); @@ -133,24 +122,15 @@ omapi_lib_init(isc_mem_t *mctx) { */ void omapi_lib_destroy() { - if (omapi_mctx != NULL && omapi_internal_mctx) { - isc_mem_destroy(&omapi_mctx); - omapi_mctx = NULL; - } - - if (omapi_socketmgr != NULL) { - isc_socketmgr_destroy(&omapi_socketmgr); - omapi_socketmgr = NULL; - } - - if (omapi_taskmgr != NULL) { - isc_taskmgr_destroy(&omapi_taskmgr); - omapi_taskmgr = NULL; - } - object_destroytypes(); handle_destroy(); auth_destroy(); + + isc_task_destroy(&omapi_task); + + omapi_mctx = NULL; + omapi_socketmgr = NULL; + omapi_taskmgr = NULL; }