mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Remove layering from isc_task, isc_app, isc_socket, isc_timer, isc_mem
This commit is contained in:
147
lib/isc/timer.c
147
lib/isc/timer.c
@@ -97,35 +97,8 @@ struct isc__timermgr {
|
||||
isc_heap_t * heap;
|
||||
};
|
||||
|
||||
/*%
|
||||
* The following are intended for internal use (indicated by "isc__"
|
||||
* prefix) but are not declared as static, allowing direct access from
|
||||
* unit tests etc.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc__timer_create(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_result_t
|
||||
isc__timer_reset(isc_timer_t *timer, isc_timertype_t type,
|
||||
const isc_time_t *expires, const isc_interval_t *interval,
|
||||
bool purge);
|
||||
isc_timertype_t
|
||||
isc_timer_gettype(isc_timer_t *timer);
|
||||
isc_result_t
|
||||
isc__timer_touch(isc_timer_t *timer);
|
||||
void
|
||||
isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp);
|
||||
void
|
||||
isc__timer_detach(isc_timer_t **timerp);
|
||||
isc_result_t
|
||||
isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp);
|
||||
void
|
||||
isc_timermgr_poke(isc_timermgr_t *manager0);
|
||||
void
|
||||
isc__timermgr_destroy(isc_timermgr_t **managerp);
|
||||
|
||||
static inline isc_result_t
|
||||
schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
|
||||
@@ -268,10 +241,10 @@ destroy(isc__timer_t *timer) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__timer_create(isc_timermgr_t *manager0, 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_timer_create(isc_timermgr_t *manager0, 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__timermgr_t *manager = (isc__timermgr_t *)manager0;
|
||||
isc__timer_t *timer;
|
||||
@@ -389,7 +362,7 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type,
|
||||
isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
|
||||
const isc_time_t *expires, const isc_interval_t *interval,
|
||||
bool purge)
|
||||
{
|
||||
@@ -479,7 +452,7 @@ isc_timer_gettype(isc_timer_t *timer0) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__timer_touch(isc_timer_t *timer0) {
|
||||
isc_timer_touch(isc_timer_t *timer0) {
|
||||
isc__timer_t *timer = (isc__timer_t *)timer0;
|
||||
isc_result_t result;
|
||||
isc_time_t now;
|
||||
@@ -510,7 +483,7 @@ isc__timer_touch(isc_timer_t *timer0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
|
||||
isc_timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
|
||||
isc__timer_t *timer = (isc__timer_t *)timer0;
|
||||
|
||||
/*
|
||||
@@ -528,7 +501,7 @@ isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__timer_detach(isc_timer_t **timerp) {
|
||||
isc_timer_detach(isc_timer_t **timerp) {
|
||||
isc__timer_t *timer;
|
||||
bool free_timer = false;
|
||||
|
||||
@@ -742,7 +715,7 @@ set_index(void *what, unsigned int index) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
|
||||
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
|
||||
isc__timermgr_t *manager;
|
||||
isc_result_t result;
|
||||
|
||||
@@ -818,7 +791,7 @@ isc_timermgr_poke(isc_timermgr_t *manager0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc__timermgr_destroy(isc_timermgr_t **managerp) {
|
||||
isc_timermgr_destroy(isc_timermgr_t **managerp) {
|
||||
isc__timermgr_t *manager;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
@@ -866,114 +839,16 @@ 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);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
|
||||
return (isc__timermgr_create(mctx, managerp));
|
||||
}
|
||||
|
||||
void
|
||||
isc_timermgr_destroy(isc_timermgr_t **managerp) {
|
||||
REQUIRE(*managerp != NULL && ISCAPI_TIMERMGR_VALID(*managerp));
|
||||
|
||||
isc__timermgr_destroy(managerp);
|
||||
|
||||
ENSURE(*managerp == NULL);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_timer_create(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)
|
||||
{
|
||||
REQUIRE(ISCAPI_TIMERMGR_VALID(manager));
|
||||
|
||||
return (isc__timer_create(manager, type, expires, interval,
|
||||
task, action, arg, timerp));
|
||||
}
|
||||
|
||||
void
|
||||
isc_timer_attach(isc_timer_t *timer, isc_timer_t **timerp) {
|
||||
REQUIRE(ISCAPI_TIMER_VALID(timer));
|
||||
REQUIRE(timerp != NULL && *timerp == NULL);
|
||||
|
||||
isc__timer_attach(timer, timerp);
|
||||
|
||||
ENSURE(*timerp == timer);
|
||||
}
|
||||
|
||||
void
|
||||
isc_timer_detach(isc_timer_t **timerp) {
|
||||
REQUIRE(timerp != NULL && ISCAPI_TIMER_VALID(*timerp));
|
||||
|
||||
isc__timer_detach(timerp);
|
||||
|
||||
ENSURE(*timerp == NULL);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_timer_reset(isc_timer_t *timer, isc_timertype_t type,
|
||||
const isc_time_t *expires, const isc_interval_t *interval,
|
||||
bool purge)
|
||||
{
|
||||
REQUIRE(ISCAPI_TIMER_VALID(timer));
|
||||
|
||||
return (isc__timer_reset(timer, type, expires,
|
||||
interval, purge));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_timer_touch(isc_timer_t *timer) {
|
||||
REQUIRE(ISCAPI_TIMER_VALID(timer));
|
||||
|
||||
return (isc__timer_touch(timer));
|
||||
}
|
||||
|
Reference in New Issue
Block a user