WiP'
This commit is contained in:
@@ -20,34 +20,10 @@
|
||||
#include <isc/once.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
static isc_mutex_t createlock;
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_appctxcreatefunc_t appctx_createfunc = NULL;
|
||||
static isc_boolean_t is_running = ISC_FALSE;
|
||||
|
||||
#define ISCAPI_APPMETHODS_VALID(m) ISC_MAGIC_VALID(m, ISCAPI_APPMETHODS_MAGIC)
|
||||
|
||||
static void
|
||||
initialize(void) {
|
||||
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_app_register(isc_appctxcreatefunc_t createfunc) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
|
||||
|
||||
LOCK(&createlock);
|
||||
if (appctx_createfunc == NULL)
|
||||
appctx_createfunc = createfunc;
|
||||
else
|
||||
result = ISC_R_EXISTS;
|
||||
UNLOCK(&createlock);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
|
||||
return (isc__appctx_create(mctx, ctxp));
|
||||
|
||||
@@ -100,41 +100,6 @@ typedef enum {
|
||||
isc_taskmgrmode_privileged
|
||||
} isc_taskmgrmode_t;
|
||||
|
||||
/*% Task and task manager methods */
|
||||
typedef struct isc_taskmgrmethods {
|
||||
void (*destroy)(isc_taskmgr_t **managerp);
|
||||
void (*setmode)(isc_taskmgr_t *manager,
|
||||
isc_taskmgrmode_t mode);
|
||||
isc_taskmgrmode_t (*mode)(isc_taskmgr_t *manager);
|
||||
isc_result_t (*taskcreate)(isc_taskmgr_t *manager,
|
||||
unsigned int quantum,
|
||||
isc_task_t **taskp);
|
||||
void (*setexcltask)(isc_taskmgr_t *mgr, isc_task_t *task);
|
||||
isc_result_t (*excltask)(isc_taskmgr_t *mgr, isc_task_t **taskp);
|
||||
} isc_taskmgrmethods_t;
|
||||
|
||||
typedef struct isc_taskmethods {
|
||||
void (*attach)(isc_task_t *source, isc_task_t **targetp);
|
||||
void (*detach)(isc_task_t **taskp);
|
||||
void (*destroy)(isc_task_t **taskp);
|
||||
void (*send)(isc_task_t *task, isc_event_t **eventp);
|
||||
void (*sendanddetach)(isc_task_t **taskp, isc_event_t **eventp);
|
||||
unsigned int (*unsend)(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
void *tag, isc_eventlist_t *events);
|
||||
isc_result_t (*onshutdown)(isc_task_t *task, isc_taskaction_t action,
|
||||
void *arg);
|
||||
void (*shutdown)(isc_task_t *task);
|
||||
void (*setname)(isc_task_t *task, const char *name, void *tag);
|
||||
unsigned int (*purgeevents)(isc_task_t *task, void *sender,
|
||||
isc_eventtype_t type, void *tag);
|
||||
unsigned int (*purgerange)(isc_task_t *task, void *sender,
|
||||
isc_eventtype_t first, isc_eventtype_t last,
|
||||
void *tag);
|
||||
isc_result_t (*beginexclusive)(isc_task_t *task);
|
||||
void (*endexclusive)(isc_task_t *task);
|
||||
void (*setprivilege)(isc_task_t *task, isc_boolean_t priv);
|
||||
isc_boolean_t (*privilege)(isc_task_t *task);
|
||||
} isc_taskmethods_t;
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of a task manager
|
||||
@@ -148,7 +113,6 @@ typedef struct isc_taskmethods {
|
||||
struct isc_taskmgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_taskmgrmethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_TASKMGR_MAGIC ISC_MAGIC('A','t','m','g')
|
||||
@@ -162,7 +126,6 @@ struct isc_taskmgr {
|
||||
struct isc_task {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_taskmethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_TASK_MAGIC ISC_MAGIC('A','t','s','t')
|
||||
|
||||
@@ -97,29 +97,6 @@ typedef struct isc_timerevent {
|
||||
#define ISC_TIMEREVENT_LIFE (ISC_EVENTCLASS_TIMER + 3)
|
||||
#define ISC_TIMEREVENT_LASTEVENT (ISC_EVENTCLASS_TIMER + 65535)
|
||||
|
||||
/*% Timer and timer manager methods */
|
||||
typedef struct {
|
||||
void (*destroy)(isc_timermgr_t **managerp);
|
||||
isc_result_t (*timercreate)(isc_timermgr_t *manager,
|
||||
isc_timertype_t type,
|
||||
const isc_time_t *expires,
|
||||
const isc_interval_t *interval,
|
||||
isc_task_t *task,
|
||||
isc_taskaction_t action,
|
||||
void *arg,
|
||||
isc_timer_t **timerp);
|
||||
} isc_timermgrmethods_t;
|
||||
|
||||
typedef struct {
|
||||
void (*attach)(isc_timer_t *timer, isc_timer_t **timerp);
|
||||
void (*detach)(isc_timer_t **timerp);
|
||||
isc_result_t (*reset)(isc_timer_t *timer, isc_timertype_t type,
|
||||
const isc_time_t *expires,
|
||||
const isc_interval_t *interval,
|
||||
isc_boolean_t purge);
|
||||
isc_result_t (*touch)(isc_timer_t *timer);
|
||||
} isc_timermethods_t;
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of a timer manager
|
||||
* object implementation's version of an isc_timermgr_t.
|
||||
@@ -132,7 +109,6 @@ typedef struct {
|
||||
struct isc_timermgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_timermgrmethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_TIMERMGR_MAGIC ISC_MAGIC('A','t','m','g')
|
||||
@@ -146,7 +122,6 @@ struct isc_timermgr {
|
||||
struct isc_timer {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_timermethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_TIMER_MAGIC ISC_MAGIC('A','t','m','r')
|
||||
|
||||
+1
-1
@@ -79,5 +79,5 @@ isc_lib_initmsgcat(void) {
|
||||
|
||||
void
|
||||
isc_lib_register(void) {
|
||||
printf("ISC_LIB_REGISTER\n");
|
||||
isc_bind9 = ISC_FALSE;
|
||||
}
|
||||
|
||||
+1
-36
@@ -109,7 +109,6 @@ static ISC_LIST(isc__mem_t) contexts;
|
||||
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_mutex_t contextslock;
|
||||
static isc_mutex_t createlock;
|
||||
|
||||
/*%
|
||||
* Total size of lost memory due to a bug of external library.
|
||||
@@ -786,7 +785,6 @@ default_memfree(void *arg, void *ptr) {
|
||||
|
||||
static void
|
||||
initialize_action(void) {
|
||||
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mutex_init(&contextslock) == ISC_R_SUCCESS);
|
||||
ISC_LIST_INIT(contexts);
|
||||
totallost = 0;
|
||||
@@ -2164,11 +2162,6 @@ isc_mempool_getfillcount(isc_mempool_t *mpctx0) {
|
||||
return (fillcount);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__mem_register(void) {
|
||||
return (isc_mem_register(isc_mem_create2));
|
||||
}
|
||||
|
||||
void
|
||||
isc__mem_printactive(isc_mem_t *ctx0, FILE *file) {
|
||||
#if ISC_MEM_TRACKLINES
|
||||
@@ -2615,39 +2608,11 @@ isc_mem_renderjson(json_object *memobj) {
|
||||
}
|
||||
#endif /* HAVE_JSON */
|
||||
|
||||
static isc_memcreatefunc_t mem_createfunc = NULL;
|
||||
|
||||
isc_result_t
|
||||
isc_mem_register(isc_memcreatefunc_t createfunc) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
|
||||
|
||||
LOCK(&createlock);
|
||||
if (mem_createfunc == NULL)
|
||||
mem_createfunc = createfunc;
|
||||
else
|
||||
result = ISC_R_EXISTS;
|
||||
UNLOCK(&createlock);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
isc_result_t
|
||||
isc__mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp,
|
||||
unsigned int flags)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
LOCK(&createlock);
|
||||
|
||||
REQUIRE(mem_createfunc != NULL);
|
||||
result = (*mem_createfunc)(init_max_size, target_size, mctxp, flags);
|
||||
|
||||
UNLOCK(&createlock);
|
||||
|
||||
return (result);
|
||||
return (isc_mem_create2(init_max_size, target_size, mctxp, flags));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
|
||||
+1
-31
@@ -19,43 +19,13 @@
|
||||
#include <isc/socket.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
static isc_mutex_t createlock;
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_socketmgrcreatefunc_t socketmgr_createfunc = NULL;
|
||||
|
||||
static void
|
||||
initialize(void) {
|
||||
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_register(isc_socketmgrcreatefunc_t createfunc) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
|
||||
|
||||
LOCK(&createlock);
|
||||
if (socketmgr_createfunc == NULL)
|
||||
socketmgr_createfunc = createfunc;
|
||||
else
|
||||
result = ISC_R_EXISTS;
|
||||
UNLOCK(&createlock);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socketmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||
isc_socketmgr_t **managerp)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
LOCK(&createlock);
|
||||
|
||||
REQUIRE(socketmgr_createfunc != NULL);
|
||||
result = (*socketmgr_createfunc)(mctx, managerp);
|
||||
|
||||
UNLOCK(&createlock);
|
||||
result = isc__socketmgr_create(mctx, managerp);
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
isc_appctx_setsocketmgr(actx, *managerp);
|
||||
|
||||
+1
-81
@@ -234,49 +234,6 @@ pop_readyq(isc__taskmgr_t *manager);
|
||||
static inline void
|
||||
push_readyq(isc__taskmgr_t *manager, isc__task_t *task);
|
||||
|
||||
static struct isc__taskmethods {
|
||||
isc_taskmethods_t methods;
|
||||
|
||||
/*%
|
||||
* The following are defined just for avoiding unused static functions.
|
||||
*/
|
||||
void *purgeevent, *unsendrange, *getname, *gettag,
|
||||
*getcurrenttime, *getcurrenttimex;
|
||||
} taskmethods = {
|
||||
{
|
||||
isc__task_attach,
|
||||
isc__task_detach,
|
||||
isc__task_destroy,
|
||||
isc__task_send,
|
||||
isc__task_sendanddetach,
|
||||
isc__task_unsend,
|
||||
isc__task_onshutdown,
|
||||
isc__task_shutdown,
|
||||
isc__task_setname,
|
||||
isc__task_purge,
|
||||
isc__task_purgerange,
|
||||
isc__task_beginexclusive,
|
||||
isc__task_endexclusive,
|
||||
isc__task_setprivilege,
|
||||
isc__task_privilege
|
||||
},
|
||||
(void *)isc_task_purgeevent,
|
||||
(void *)isc__task_unsendrange,
|
||||
(void *)isc__task_getname,
|
||||
(void *)isc__task_gettag,
|
||||
(void *)isc__task_getcurrenttime,
|
||||
(void *)isc__task_getcurrenttimex
|
||||
};
|
||||
|
||||
static isc_taskmgrmethods_t taskmgrmethods = {
|
||||
isc__taskmgr_destroy,
|
||||
isc__taskmgr_setmode,
|
||||
isc__taskmgr_mode,
|
||||
isc__task_create,
|
||||
isc_taskmgr_setexcltask,
|
||||
isc_taskmgr_excltask
|
||||
};
|
||||
|
||||
/***
|
||||
*** Tasks.
|
||||
***/
|
||||
@@ -365,7 +322,6 @@ isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
|
||||
return (ISC_R_SHUTTINGDOWN);
|
||||
}
|
||||
|
||||
task->common.methods = (isc_taskmethods_t *)&taskmethods;
|
||||
task->common.magic = ISCAPI_TASK_MAGIC;
|
||||
task->common.impmagic = TASK_MAGIC;
|
||||
*taskp = (isc_task_t *)task;
|
||||
@@ -1297,7 +1253,6 @@ isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
manager = isc_mem_get(mctx, sizeof(*manager));
|
||||
if (manager == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
manager->common.methods = &taskmgrmethods;
|
||||
manager->common.impmagic = TASK_MANAGER_MAGIC;
|
||||
manager->common.magic = ISCAPI_TASKMGR_MAGIC;
|
||||
manager->mode = isc_taskmgrmode_normal;
|
||||
@@ -1631,11 +1586,6 @@ isc__task_privilege(isc_task_t *task0) {
|
||||
return (priv);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__task_register(void) {
|
||||
return (isc_task_register(isc__taskmgr_create));
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
isc_task_exiting(isc_task_t *t) {
|
||||
isc__task_t *task = (isc__task_t *)t;
|
||||
@@ -1841,31 +1791,6 @@ isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, json_object *tasks) {
|
||||
#endif
|
||||
|
||||
|
||||
static isc_mutex_t createlock;
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_taskmgrcreatefunc_t taskmgr_createfunc = NULL;
|
||||
|
||||
static void
|
||||
initialize(void) {
|
||||
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_task_register(isc_taskmgrcreatefunc_t createfunc) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
|
||||
|
||||
LOCK(&createlock);
|
||||
if (taskmgr_createfunc == NULL)
|
||||
taskmgr_createfunc = createfunc;
|
||||
else
|
||||
result = ISC_R_EXISTS;
|
||||
UNLOCK(&createlock);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||
unsigned int workers, unsigned int default_quantum,
|
||||
@@ -1873,14 +1798,9 @@ isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
LOCK(&createlock);
|
||||
|
||||
REQUIRE(taskmgr_createfunc != NULL);
|
||||
result = (*taskmgr_createfunc)(mctx, workers, default_quantum,
|
||||
result = isc__taskmgr_create(mctx, workers, default_quantum,
|
||||
managerp);
|
||||
|
||||
UNLOCK(&createlock);
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
isc_appctx_settaskmgr(actx, *managerp);
|
||||
|
||||
|
||||
+1
-36
@@ -899,48 +899,13 @@ isc__timermgr_destroy(isc_timermgr_t **managerp) {
|
||||
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__timer_register(void) {
|
||||
return (isc_timer_register(isc__timermgr_create));
|
||||
}
|
||||
|
||||
static isc_mutex_t createlock;
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_timermgrcreatefunc_t timermgr_createfunc = NULL;
|
||||
|
||||
static void
|
||||
initialize(void) {
|
||||
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_timer_register(isc_timermgrcreatefunc_t createfunc) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
|
||||
|
||||
LOCK(&createlock);
|
||||
if (timermgr_createfunc == NULL)
|
||||
timermgr_createfunc = createfunc;
|
||||
else
|
||||
result = ISC_R_EXISTS;
|
||||
UNLOCK(&createlock);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_timermgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||
isc_timermgr_t **managerp)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
LOCK(&createlock);
|
||||
|
||||
REQUIRE(timermgr_createfunc != NULL);
|
||||
result = (*timermgr_createfunc)(mctx, managerp);
|
||||
|
||||
UNLOCK(&createlock);
|
||||
result = isc__timermgr_create(mctx, managerp);
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
isc_appctx_settimermgr(actx, *managerp);
|
||||
|
||||
@@ -775,9 +775,4 @@ isc__appctx_settimermgr(isc_appctx_t *ctx0, isc_timermgr_t *timermgr) {
|
||||
ctx->timermgr = timermgr;
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__app_register(void) {
|
||||
return (isc_app_register(isc__appctx_create));
|
||||
}
|
||||
|
||||
#include "../app_api.c"
|
||||
|
||||
@@ -6235,11 +6235,6 @@ isc__socket_gettag(isc_socket_t *socket0) {
|
||||
return (sock->tag);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__socket_register(void) {
|
||||
return (isc_socket_register(isc__socketmgr_create));
|
||||
}
|
||||
|
||||
int
|
||||
isc__socket_getfd(isc_socket_t *socket0) {
|
||||
isc__socket_t *sock = (isc__socket_t *)socket0;
|
||||
|
||||
Reference in New Issue
Block a user