#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 bool is_running = 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));
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, bool priv);
- bool (*privilege)(isc_task_t *task);
-} isc_taskmethods_t;
-
/*%
* This structure is actually just the common prefix of a task manager
* object implementation's version of an isc_taskmgr_t.
struct isc_taskmgr {
unsigned int impmagic;
unsigned int magic;
- isc_taskmgrmethods_t *methods;
};
#define ISCAPI_TASKMGR_MAGIC ISC_MAGIC('A','t','m','g')
struct isc_task {
unsigned int impmagic;
unsigned int magic;
- isc_taskmethods_t *methods;
};
#define ISCAPI_TASK_MAGIC ISC_MAGIC('A','t','s','t')
#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,
- bool 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.
struct isc_timermgr {
unsigned int impmagic;
unsigned int magic;
- isc_timermgrmethods_t *methods;
};
#define ISCAPI_TIMERMGR_MAGIC ISC_MAGIC('A','t','m','g')
struct isc_timer {
unsigned int impmagic;
unsigned int magic;
- isc_timermethods_t *methods;
};
#define ISCAPI_TIMER_MAGIC ISC_MAGIC('A','t','m','r')
void
isc_lib_register(void) {
- printf("ISC_LIB_REGISTER\n");
+ isc_bind9 = ISC_FALSE;
}
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.
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;
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
}
#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
#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);
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.
***/
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;
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;
return (priv);
}
-isc_result_t
-isc__task_register(void) {
- return (isc_task_register(isc__taskmgr_create));
-}
-
bool
isc_task_exiting(isc_task_t *t) {
isc__task_t *task = (isc__task_t *)t;
#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,
{
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);
}
-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);
ctx->timermgr = timermgr;
}
-isc_result_t
-isc__app_register(void) {
- return (isc_app_register(isc__appctx_create));
-}
-
#include "../app_api.c"
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;