mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Require a taskmgr and socketmgr for omapi_lib_init.
Create an omapi_task in omapi_lib_init and destroy it in omapi_lib_destroy.
This commit is contained in:
@@ -41,11 +41,10 @@ omapi_objecttype_t *omapi_type_message;
|
|||||||
omapi_objecttype_t *omapi_object_types;
|
omapi_objecttype_t *omapi_object_types;
|
||||||
|
|
||||||
isc_mem_t *omapi_mctx;
|
isc_mem_t *omapi_mctx;
|
||||||
|
isc_task_t *omapi_task;
|
||||||
isc_taskmgr_t *omapi_taskmgr;
|
isc_taskmgr_t *omapi_taskmgr;
|
||||||
isc_socketmgr_t *omapi_socketmgr;
|
isc_socketmgr_t *omapi_socketmgr;
|
||||||
|
|
||||||
isc_boolean_t omapi_internal_mctx = ISC_FALSE;
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*** Private to lib.c.
|
*** Private to lib.c.
|
||||||
***/
|
***/
|
||||||
@@ -72,7 +71,9 @@ omapi_lib_initmsgcat(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
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;
|
isc_result_t result;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -81,35 +82,23 @@ omapi_lib_init(isc_mem_t *mctx) {
|
|||||||
REQUIRE(omapi_mctx == NULL &&
|
REQUIRE(omapi_mctx == NULL &&
|
||||||
omapi_socketmgr == NULL &&
|
omapi_socketmgr == NULL &&
|
||||||
omapi_taskmgr == NULL &&
|
omapi_taskmgr == NULL &&
|
||||||
|
omapi_task == NULL &&
|
||||||
omapi_object_types == NULL);
|
omapi_object_types == NULL);
|
||||||
|
|
||||||
if (mctx != NULL)
|
REQUIRE(mctx != NULL && taskmgr != NULL && socketmgr != NULL);
|
||||||
omapi_mctx = mctx;
|
|
||||||
|
|
||||||
else {
|
omapi_mctx = mctx;
|
||||||
omapi_internal_mctx = ISC_TRUE;
|
omapi_taskmgr = taskmgr;
|
||||||
result = isc_mem_create(0, 0, &omapi_mctx);
|
omapi_socketmgr = socketmgr;
|
||||||
if (result != ISC_R_SUCCESS)
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = isc_socketmgr_create(omapi_mctx, &omapi_socketmgr);
|
result = isc_task_create(omapi_taskmgr, omapi_mctx, 0, &omapi_task);
|
||||||
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);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the standard object types.
|
* Initialize the standard object types.
|
||||||
*/
|
*/
|
||||||
result = generic_init();
|
if (result == ISC_R_SUCCESS)
|
||||||
|
result = generic_init();
|
||||||
|
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result == ISC_R_SUCCESS)
|
||||||
result = listener_init();
|
result = listener_init();
|
||||||
|
|
||||||
@@ -133,24 +122,15 @@ omapi_lib_init(isc_mem_t *mctx) {
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
omapi_lib_destroy() {
|
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();
|
object_destroytypes();
|
||||||
|
|
||||||
handle_destroy();
|
handle_destroy();
|
||||||
|
|
||||||
auth_destroy();
|
auth_destroy();
|
||||||
|
|
||||||
|
isc_task_destroy(&omapi_task);
|
||||||
|
|
||||||
|
omapi_mctx = NULL;
|
||||||
|
omapi_socketmgr = NULL;
|
||||||
|
omapi_taskmgr = NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user