2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 15:45:25 +00:00

Get rid of isc_bind9 conditional

This commit is contained in:
Witold Kręcicki
2018-08-06 12:15:50 +02:00
parent 60f22ff410
commit cdbac34cba
11 changed files with 102 additions and 742 deletions

View File

@@ -51,30 +51,14 @@ isc_app_register(isc_appctxcreatefunc_t createfunc) {
isc_result_t isc_result_t
isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) { isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
isc_result_t result;
if (isc_bind9)
return (isc__appctx_create(mctx, ctxp)); return (isc__appctx_create(mctx, ctxp));
LOCK(&createlock);
REQUIRE(appctx_createfunc != NULL);
result = (*appctx_createfunc)(mctx, ctxp);
UNLOCK(&createlock);
return (result);
} }
void void
isc_appctx_destroy(isc_appctx_t **ctxp) { isc_appctx_destroy(isc_appctx_t **ctxp) {
REQUIRE(ctxp != NULL && ISCAPI_APPCTX_VALID(*ctxp)); REQUIRE(ctxp != NULL && ISCAPI_APPCTX_VALID(*ctxp));
if (isc_bind9)
isc__appctx_destroy(ctxp); isc__appctx_destroy(ctxp);
else
(*ctxp)->methods->ctxdestroy(ctxp);
ENSURE(*ctxp == NULL); ENSURE(*ctxp == NULL);
} }
@@ -82,20 +66,14 @@ isc_result_t
isc_app_ctxstart(isc_appctx_t *ctx) { isc_app_ctxstart(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx)); REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxstart(ctx)); return (isc__app_ctxstart(ctx));
return (ctx->methods->ctxstart(ctx));
} }
isc_result_t isc_result_t
isc_app_ctxrun(isc_appctx_t *ctx) { isc_app_ctxrun(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx)); REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxrun(ctx)); return (isc__app_ctxrun(ctx));
return (ctx->methods->ctxrun(ctx));
} }
isc_result_t isc_result_t
@@ -105,40 +83,28 @@ isc_app_ctxonrun(isc_appctx_t *ctx, isc_mem_t *mctx,
{ {
REQUIRE(ISCAPI_APPCTX_VALID(ctx)); REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxonrun(ctx, mctx, task, action, arg)); return (isc__app_ctxonrun(ctx, mctx, task, action, arg));
return (ctx->methods->ctxonrun(ctx, mctx, task, action, arg));
} }
isc_result_t isc_result_t
isc_app_ctxsuspend(isc_appctx_t *ctx) { isc_app_ctxsuspend(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx)); REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxsuspend(ctx)); return (isc__app_ctxsuspend(ctx));
return (ctx->methods->ctxsuspend(ctx));
} }
isc_result_t isc_result_t
isc_app_ctxshutdown(isc_appctx_t *ctx) { isc_app_ctxshutdown(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx)); REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxshutdown(ctx)); return (isc__app_ctxshutdown(ctx));
return (ctx->methods->ctxshutdown(ctx));
} }
void void
isc_app_ctxfinish(isc_appctx_t *ctx) { isc_app_ctxfinish(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx)); REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
isc__app_ctxfinish(ctx); isc__app_ctxfinish(ctx);
ctx->methods->ctxfinish(ctx);
} }
void void
@@ -146,10 +112,7 @@ isc_appctx_settaskmgr(isc_appctx_t *ctx, isc_taskmgr_t *taskmgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx)); REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(taskmgr != NULL); REQUIRE(taskmgr != NULL);
if (isc_bind9)
isc__appctx_settaskmgr(ctx, taskmgr); isc__appctx_settaskmgr(ctx, taskmgr);
ctx->methods->settaskmgr(ctx, taskmgr);
} }
void void
@@ -157,10 +120,7 @@ isc_appctx_setsocketmgr(isc_appctx_t *ctx, isc_socketmgr_t *socketmgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx)); REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(socketmgr != NULL); REQUIRE(socketmgr != NULL);
if (isc_bind9)
isc__appctx_setsocketmgr(ctx, socketmgr); isc__appctx_setsocketmgr(ctx, socketmgr);
ctx->methods->setsocketmgr(ctx, socketmgr);
} }
void void
@@ -168,43 +128,30 @@ isc_appctx_settimermgr(isc_appctx_t *ctx, isc_timermgr_t *timermgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx)); REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(timermgr != NULL); REQUIRE(timermgr != NULL);
if (isc_bind9)
isc__appctx_settimermgr(ctx, timermgr); isc__appctx_settimermgr(ctx, timermgr);
ctx->methods->settimermgr(ctx, timermgr);
} }
isc_result_t isc_result_t
isc_app_start(void) { isc_app_start(void) {
if (isc_bind9)
return (isc__app_start()); return (isc__app_start());
return (ISC_R_NOTIMPLEMENTED);
} }
isc_result_t isc_result_t
isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_app_onrun(isc_mem_t *mctx, isc_task_t *task,
isc_taskaction_t action, void *arg) isc_taskaction_t action, void *arg)
{ {
if (isc_bind9)
return (isc__app_onrun(mctx, task, action, arg)); return (isc__app_onrun(mctx, task, action, arg));
return (ISC_R_NOTIMPLEMENTED);
} }
isc_result_t isc_result_t
isc_app_run() { isc_app_run() {
if (isc_bind9) {
isc_result_t result; isc_result_t result;
is_running = true; is_running = ISC_TRUE;
result = isc__app_run(); result = isc__app_run();
is_running = false; is_running = ISC_FALSE;
return (result); return (result);
}
return (ISC_R_NOTIMPLEMENTED);
} }
bool bool
@@ -214,40 +161,25 @@ isc_app_isrunning() {
isc_result_t isc_result_t
isc_app_shutdown(void) { isc_app_shutdown(void) {
if (isc_bind9)
return (isc__app_shutdown()); return (isc__app_shutdown());
return (ISC_R_NOTIMPLEMENTED);
} }
isc_result_t isc_result_t
isc_app_reload(void) { isc_app_reload(void) {
if (isc_bind9)
return (isc__app_reload()); return (isc__app_reload());
return (ISC_R_NOTIMPLEMENTED);
} }
void void
isc_app_finish(void) { isc_app_finish(void) {
if (!isc_bind9)
return;
isc__app_finish(); isc__app_finish();
} }
void void
isc_app_block(void) { isc_app_block(void) {
if (!isc_bind9)
return;
isc__app_block(); isc__app_block();
} }
void void
isc_app_unblock(void) { isc_app_unblock(void) {
if (!isc_bind9)
return;
isc__app_unblock(); isc__app_unblock();
} }

View File

@@ -94,29 +94,6 @@ typedef isc_event_t isc_appevent_t;
#define ISC_APPEVENT_SHUTDOWN (ISC_EVENTCLASS_APP + 1) #define ISC_APPEVENT_SHUTDOWN (ISC_EVENTCLASS_APP + 1)
#define ISC_APPEVENT_LASTEVENT (ISC_EVENTCLASS_APP + 65535) #define ISC_APPEVENT_LASTEVENT (ISC_EVENTCLASS_APP + 65535)
/*%
* app module methods. Only app driver implementations use this structure.
* Other clients should use the top-level interfaces (i.e., isc_app_xxx
* functions). magic must be ISCAPI_APPMETHODS_MAGIC.
*/
typedef struct isc_appmethods {
void (*ctxdestroy)(isc_appctx_t **ctxp);
isc_result_t (*ctxstart)(isc_appctx_t *ctx);
isc_result_t (*ctxrun)(isc_appctx_t *ctx);
isc_result_t (*ctxsuspend)(isc_appctx_t *ctx);
isc_result_t (*ctxshutdown)(isc_appctx_t *ctx);
void (*ctxfinish)(isc_appctx_t *ctx);
void (*settaskmgr)(isc_appctx_t *ctx,
isc_taskmgr_t *timermgr);
void (*setsocketmgr)(isc_appctx_t *ctx,
isc_socketmgr_t *timermgr);
void (*settimermgr)(isc_appctx_t *ctx,
isc_timermgr_t *timermgr);
isc_result_t (*ctxonrun)(isc_appctx_t *ctx, isc_mem_t *mctx,
isc_task_t *task, isc_taskaction_t action,
void *arg);
} isc_appmethods_t;
/*% /*%
* This structure is actually just the common prefix of an application context * This structure is actually just the common prefix of an application context
* implementation's version of an isc_appctx_t. * implementation's version of an isc_appctx_t.
@@ -129,7 +106,6 @@ typedef struct isc_appmethods {
struct isc_appctx { struct isc_appctx {
unsigned int impmagic; unsigned int impmagic;
unsigned int magic; unsigned int magic;
isc_appmethods_t *methods;
}; };
#define ISCAPI_APPCTX_MAGIC ISC_MAGIC('A','a','p','c') #define ISCAPI_APPCTX_MAGIC ISC_MAGIC('A','a','p','c')

View File

@@ -181,44 +181,6 @@ LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_defaultflags;
* \endcode * \endcode
*/ */
/*% memory and memory pool methods */
typedef struct isc_memmethods {
void (*attach)(isc_mem_t *source, isc_mem_t **targetp);
void (*detach)(isc_mem_t **mctxp);
void (*destroy)(isc_mem_t **mctxp);
void *(*memget)(isc_mem_t *mctx, size_t size _ISC_MEM_FLARG);
void (*memput)(isc_mem_t *mctx, void *ptr, size_t size _ISC_MEM_FLARG);
void (*memputanddetach)(isc_mem_t **mctxp, void *ptr,
size_t size _ISC_MEM_FLARG);
void *(*memallocate)(isc_mem_t *mctx, size_t size _ISC_MEM_FLARG);
void *(*memreallocate)(isc_mem_t *mctx, void *ptr,
size_t size _ISC_MEM_FLARG);
char *(*memstrdup)(isc_mem_t *mctx, const char *s _ISC_MEM_FLARG);
void (*memfree)(isc_mem_t *mctx, void *ptr _ISC_MEM_FLARG);
void (*setdestroycheck)(isc_mem_t *mctx, bool flag);
void (*setwater)(isc_mem_t *ctx, isc_mem_water_t water,
void *water_arg, size_t hiwater, size_t lowater);
void (*waterack)(isc_mem_t *ctx, int flag);
size_t (*inuse)(isc_mem_t *mctx);
size_t (*maxinuse)(isc_mem_t *mctx);
size_t (*total)(isc_mem_t *mctx);
bool (*isovermem)(isc_mem_t *mctx);
isc_result_t (*mpcreate)(isc_mem_t *mctx, size_t size,
isc_mempool_t **mpctxp);
} isc_memmethods_t;
typedef struct isc_mempoolmethods {
void (*destroy)(isc_mempool_t **mpctxp);
void *(*get)(isc_mempool_t *mpctx _ISC_MEM_FLARG);
void (*put)(isc_mempool_t *mpctx, void *mem _ISC_MEM_FLARG);
unsigned int (*getallocated)(isc_mempool_t *mpctx);
void (*setmaxalloc)(isc_mempool_t *mpctx, unsigned int limit);
void (*setfreemax)(isc_mempool_t *mpctx, unsigned int limit);
void (*setname)(isc_mempool_t *mpctx, const char *name);
void (*associatelock)(isc_mempool_t *mpctx, isc_mutex_t *lock);
void (*setfillcount)(isc_mempool_t *mpctx, unsigned int limit);
} isc_mempoolmethods_t;
/*% /*%
* This structure is actually just the common prefix of a memory context * This structure is actually just the common prefix of a memory context
* implementation's version of an isc_mem_t. * implementation's version of an isc_mem_t.
@@ -231,7 +193,6 @@ typedef struct isc_mempoolmethods {
struct isc_mem { struct isc_mem {
unsigned int impmagic; unsigned int impmagic;
unsigned int magic; unsigned int magic;
isc_memmethods_t *methods;
}; };
#define ISCAPI_MCTX_MAGIC ISC_MAGIC('A','m','c','x') #define ISCAPI_MCTX_MAGIC ISC_MAGIC('A','m','c','x')
@@ -245,7 +206,6 @@ struct isc_mem {
struct isc_mempool { struct isc_mempool {
unsigned int impmagic; unsigned int impmagic;
unsigned int magic; unsigned int magic;
isc_mempoolmethods_t *methods;
}; };
#define ISCAPI_MPOOL_MAGIC ISC_MAGIC('A','m','p','l') #define ISCAPI_MPOOL_MAGIC ISC_MAGIC('A','m','p','l')

View File

@@ -333,60 +333,6 @@ typedef enum {
#define ISC_SOCKFDWATCH_WRITE 0x00000002 /*%< watch for writable */ #define ISC_SOCKFDWATCH_WRITE 0x00000002 /*%< watch for writable */
/*@}*/ /*@}*/
/*% Socket and socket manager methods */
typedef struct isc_socketmgrmethods {
void (*destroy)(isc_socketmgr_t **managerp);
isc_result_t (*socketcreate)(isc_socketmgr_t *manager, int pf,
isc_sockettype_t type,
isc_socket_t **socketp);
isc_result_t (*fdwatchcreate)(isc_socketmgr_t *manager, int fd,
int flags,
isc_sockfdwatch_t callback,
void *cbarg, isc_task_t *task,
isc_socket_t **socketp);
} isc_socketmgrmethods_t;
typedef struct isc_socketmethods {
void (*attach)(isc_socket_t *socket,
isc_socket_t **socketp);
void (*detach)(isc_socket_t **socketp);
isc_result_t (*bind)(isc_socket_t *sock,
const isc_sockaddr_t *sockaddr,
isc_socket_options_t options);
isc_result_t (*sendto)(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task, isc_taskaction_t action,
void *arg,
const isc_sockaddr_t *address,
struct in6_pktinfo *pktinfo);
isc_result_t (*sendto2)(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task,
const isc_sockaddr_t *address,
struct in6_pktinfo *pktinfo,
isc_socketevent_t *event,
unsigned int flags);
isc_result_t (*connect)(isc_socket_t *sock,
const isc_sockaddr_t *addr,
isc_task_t *task, isc_taskaction_t action,
void *arg);
isc_result_t (*recv)(isc_socket_t *sock, isc_region_t *region,
unsigned int minimum, isc_task_t *task,
isc_taskaction_t action, void *arg);
isc_result_t (*recv2)(isc_socket_t *sock, isc_region_t *region,
unsigned int minimum, isc_task_t *task,
isc_socketevent_t *event, unsigned int flags);
void (*cancel)(isc_socket_t *sock, isc_task_t *task,
unsigned int how);
isc_result_t (*getsockname)(isc_socket_t *sock,
isc_sockaddr_t *addressp);
isc_sockettype_t (*gettype)(isc_socket_t *sock);
void (*ipv6only)(isc_socket_t *sock, bool yes);
isc_result_t (*fdwatchpoke)(isc_socket_t *sock, int flags);
isc_result_t (*dup)(isc_socket_t *socket,
isc_socket_t **socketp);
int (*getfd)(isc_socket_t *socket);
void (*dscp)(isc_socket_t *socket, isc_dscp_t dscp);
} isc_socketmethods_t;
/*% /*%
* This structure is actually just the common prefix of a socket manager * This structure is actually just the common prefix of a socket manager
* object implementation's version of an isc_socketmgr_t. * object implementation's version of an isc_socketmgr_t.
@@ -404,7 +350,6 @@ typedef struct isc_socketmethods {
struct isc_socketmgr { struct isc_socketmgr {
unsigned int impmagic; unsigned int impmagic;
unsigned int magic; unsigned int magic;
isc_socketmgrmethods_t *methods;
}; };
#endif #endif
@@ -420,7 +365,6 @@ struct isc_socketmgr {
struct isc_socket { struct isc_socket {
unsigned int impmagic; unsigned int impmagic;
unsigned int magic; unsigned int magic;
isc_socketmethods_t *methods;
}; };
#endif #endif

View File

@@ -77,21 +77,7 @@ isc_lib_initmsgcat(void) {
} }
} }
static isc_once_t register_once = ISC_ONCE_INIT;
static void
do_register(void) {
isc_bind9 = false;
RUNTIME_CHECK(isc__mem_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__app_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__task_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__socket_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__timer_register() == ISC_R_SUCCESS);
}
void void
isc_lib_register(void) { isc_lib_register(void) {
RUNTIME_CHECK(isc_once_do(&register_once, do_register) printf("ISC_LIB_REGISTER\n");
== ISC_R_SUCCESS);
} }

View File

@@ -309,71 +309,6 @@ isc__mem_printactive(isc_mem_t *ctx0, FILE *file);
unsigned int unsigned int
isc__mem_references(isc_mem_t *ctx0); isc__mem_references(isc_mem_t *ctx0);
static struct isc__memmethods {
isc_memmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *createx, *create, *create2, *stats,
*setquota, *getquota, *setname, *getname, *gettag;
} memmethods = {
{
isc__mem_attach,
isc__mem_detach,
isc__mem_destroy,
isc___mem_get,
isc___mem_put,
isc___mem_putanddetach,
isc___mem_allocate,
isc___mem_reallocate,
isc___mem_strdup,
isc___mem_free,
isc__mem_setdestroycheck,
isc__mem_setwater,
isc__mem_waterack,
isc__mem_inuse,
isc__mem_maxinuse,
isc__mem_total,
isc__mem_isovermem,
isc__mempool_create
},
(void *)isc_mem_createx,
(void *)isc_mem_create,
(void *)isc_mem_create2,
(void *)isc_mem_stats,
(void *)isc_mem_setquota,
(void *)isc_mem_getquota,
(void *)isc_mem_setname,
(void *)isc_mem_getname,
(void *)isc_mem_gettag
};
static struct isc__mempoolmethods {
isc_mempoolmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *getfreemax, *getfreecount, *getmaxalloc, *getfillcount;
} mempoolmethods = {
{
isc__mempool_destroy,
isc___mempool_get,
isc___mempool_put,
isc__mempool_getallocated,
isc__mempool_setmaxalloc,
isc__mempool_setfreemax,
isc__mempool_setname,
isc__mempool_associatelock,
isc__mempool_setfillcount
},
(void *)isc_mempool_getfreemax,
(void *)isc_mempool_getfreecount,
(void *)isc_mempool_getmaxalloc,
(void *)isc_mempool_getfillcount
};
#if ISC_MEM_TRACKLINES #if ISC_MEM_TRACKLINES
/*! /*!
* mctx must be locked. * mctx must be locked.
@@ -923,7 +858,6 @@ isc_mem_createx2(size_t init_max_size, size_t target_size,
ctx->water_arg = NULL; ctx->water_arg = NULL;
ctx->common.impmagic = MEM_MAGIC; ctx->common.impmagic = MEM_MAGIC;
ctx->common.magic = ISCAPI_MCTX_MAGIC; ctx->common.magic = ISCAPI_MCTX_MAGIC;
ctx->common.methods = (isc_memmethods_t *)&memmethods;
ctx->memalloc = memalloc; ctx->memalloc = memalloc;
ctx->memfree = memfree; ctx->memfree = memfree;
ctx->arg = arg; ctx->arg = arg;
@@ -1801,7 +1735,6 @@ isc__mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
if (mpctx == NULL) if (mpctx == NULL)
return (ISC_R_NOMEMORY); return (ISC_R_NOMEMORY);
mpctx->common.methods = (isc_mempoolmethods_t *)&mempoolmethods;
mpctx->common.impmagic = MEMPOOL_MAGIC; mpctx->common.impmagic = MEMPOOL_MAGIC;
mpctx->common.magic = ISCAPI_MPOOL_MAGIC; mpctx->common.magic = ISCAPI_MPOOL_MAGIC;
mpctx->lock = NULL; mpctx->lock = NULL;
@@ -2684,32 +2617,15 @@ isc__mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp,
isc_result_t isc_result_t
isc_mem_create(size_t init_max_size, size_t target_size, isc_mem_t **mctxp) { isc_mem_create(size_t init_max_size, size_t target_size, isc_mem_t **mctxp) {
isc_result_t result;
if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size, return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree, default_memalloc, default_memfree,
NULL, mctxp, isc_mem_defaultflags)); NULL, mctxp, isc_mem_defaultflags));
LOCK(&createlock);
REQUIRE(mem_createfunc != NULL);
result = (*mem_createfunc)(init_max_size, target_size, mctxp,
isc_mem_defaultflags);
UNLOCK(&createlock);
return (result);
} }
isc_result_t isc_result_t
isc_mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp, isc_mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp,
unsigned int flags) unsigned int flags)
{ {
if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, flags));
return (isc_mem_createx2(init_max_size, target_size, return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree, default_memalloc, default_memfree,
NULL, mctxp, flags)); NULL, mctxp, flags));
@@ -2720,10 +2636,7 @@ isc_mem_attach(isc_mem_t *source, isc_mem_t **targetp) {
REQUIRE(ISCAPI_MCTX_VALID(source)); REQUIRE(ISCAPI_MCTX_VALID(source));
REQUIRE(targetp != NULL && *targetp == NULL); REQUIRE(targetp != NULL && *targetp == NULL);
if (isc_bind9)
isc__mem_attach(source, targetp); isc__mem_attach(source, targetp);
else
source->methods->attach(source, targetp);
ENSURE(*targetp == source); ENSURE(*targetp == source);
} }
@@ -2732,10 +2645,7 @@ void
isc_mem_detach(isc_mem_t **mctxp) { isc_mem_detach(isc_mem_t **mctxp) {
REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp)); REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp));
if (isc_bind9)
isc__mem_detach(mctxp); isc__mem_detach(mctxp);
else
(*mctxp)->methods->detach(mctxp);
ENSURE(*mctxp == NULL); ENSURE(*mctxp == NULL);
} }
@@ -2744,10 +2654,7 @@ void
isc_mem_destroy(isc_mem_t **mctxp) { isc_mem_destroy(isc_mem_t **mctxp) {
REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp)); REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp));
if (isc_bind9)
isc__mem_destroy(mctxp); isc__mem_destroy(mctxp);
else
(*mctxp)->methods->destroy(mctxp);
ENSURE(*mctxp == NULL); ENSURE(*mctxp == NULL);
} }
@@ -2756,7 +2663,7 @@ void
isc_mem_setdestroycheck(isc_mem_t *mctx, bool flag) { isc_mem_setdestroycheck(isc_mem_t *mctx, bool flag) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
mctx->methods->setdestroycheck(mctx, flag); isc__mem_setdestroycheck(mctx, flag);
} }
void void
@@ -2765,60 +2672,42 @@ isc_mem_setwater(isc_mem_t *ctx, isc_mem_water_t water, void *water_arg,
{ {
REQUIRE(ISCAPI_MCTX_VALID(ctx)); REQUIRE(ISCAPI_MCTX_VALID(ctx));
if (isc_bind9)
isc__mem_setwater(ctx, water, water_arg, hiwater, lowater); isc__mem_setwater(ctx, water, water_arg, hiwater, lowater);
else
ctx->methods->setwater(ctx, water, water_arg, hiwater, lowater);
} }
void void
isc_mem_waterack(isc_mem_t *ctx, int flag) { isc_mem_waterack(isc_mem_t *ctx, int flag) {
REQUIRE(ISCAPI_MCTX_VALID(ctx)); REQUIRE(ISCAPI_MCTX_VALID(ctx));
if (isc_bind9)
isc__mem_waterack(ctx, flag); isc__mem_waterack(ctx, flag);
else
ctx->methods->waterack(ctx, flag);
} }
size_t size_t
isc_mem_inuse(isc_mem_t *mctx) { isc_mem_inuse(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_inuse(mctx)); return (isc__mem_inuse(mctx));
return (mctx->methods->inuse(mctx));
} }
size_t size_t
isc_mem_maxinuse(isc_mem_t *mctx) { isc_mem_maxinuse(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_maxinuse(mctx)); return (isc__mem_maxinuse(mctx));
return (mctx->methods->maxinuse(mctx));
} }
size_t size_t
isc_mem_total(isc_mem_t *mctx) { isc_mem_total(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_total(mctx)); return (isc__mem_total(mctx));
return (mctx->methods->total(mctx));
} }
bool bool
isc_mem_isovermem(isc_mem_t *mctx) { isc_mem_isovermem(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_isovermem(mctx)); return (isc__mem_isovermem(mctx));
return (mctx->methods->isovermem(mctx));
} }
@@ -2826,17 +2715,14 @@ isc_result_t
isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp) { isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
return (mctx->methods->mpcreate(mctx, size, mpctxp)); return (isc__mempool_create(mctx, size, mpctxp));
} }
void void
isc_mempool_destroy(isc_mempool_t **mpctxp) { isc_mempool_destroy(isc_mempool_t **mpctxp) {
REQUIRE(mpctxp != NULL && ISCAPI_MPOOL_VALID(*mpctxp)); REQUIRE(mpctxp != NULL && ISCAPI_MPOOL_VALID(*mpctxp));
if (isc_bind9)
isc__mempool_destroy(mpctxp); isc__mempool_destroy(mpctxp);
else
(*mpctxp)->methods->destroy(mpctxp);
ENSURE(*mpctxp == NULL); ENSURE(*mpctxp == NULL);
} }
@@ -2845,91 +2731,64 @@ unsigned int
isc_mempool_getallocated(isc_mempool_t *mpctx) { isc_mempool_getallocated(isc_mempool_t *mpctx) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx)); REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
return (isc__mempool_getallocated(mpctx)); return (isc__mempool_getallocated(mpctx));
return (mpctx->methods->getallocated(mpctx));
} }
void void
isc_mempool_setmaxalloc(isc_mempool_t *mpctx, unsigned int limit) { isc_mempool_setmaxalloc(isc_mempool_t *mpctx, unsigned int limit) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx)); REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_setmaxalloc(mpctx, limit); isc__mempool_setmaxalloc(mpctx, limit);
else
mpctx->methods->setmaxalloc(mpctx, limit);
} }
void void
isc_mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit) { isc_mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx)); REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_setfreemax(mpctx, limit); isc__mempool_setfreemax(mpctx, limit);
else
mpctx->methods->setfreemax(mpctx, limit);
} }
void void
isc_mempool_setname(isc_mempool_t *mpctx, const char *name) { isc_mempool_setname(isc_mempool_t *mpctx, const char *name) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx)); REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_setname(mpctx, name); isc__mempool_setname(mpctx, name);
else
mpctx->methods->setname(mpctx, name);
} }
void void
isc_mempool_associatelock(isc_mempool_t *mpctx, isc_mutex_t *lock) { isc_mempool_associatelock(isc_mempool_t *mpctx, isc_mutex_t *lock) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx)); REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_associatelock(mpctx, lock); isc__mempool_associatelock(mpctx, lock);
else
mpctx->methods->associatelock(mpctx, lock);
} }
void void
isc_mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit) { isc_mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx)); REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_setfillcount(mpctx, limit); isc__mempool_setfillcount(mpctx, limit);
else
mpctx->methods->setfillcount(mpctx, limit);
} }
void * void *
isc__mem_get(isc_mem_t *mctx, size_t size FLARG) { isc__mem_get(isc_mem_t *mctx, size_t size FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc___mem_get(mctx, size FLARG_PASS)); return (isc___mem_get(mctx, size FLARG_PASS));
return (mctx->methods->memget(mctx, size FLARG_PASS));
} }
void void
isc__mem_put(isc_mem_t *mctx, void *ptr, size_t size FLARG) { isc__mem_put(isc_mem_t *mctx, void *ptr, size_t size FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
isc___mem_put(mctx, ptr, size FLARG_PASS); isc___mem_put(mctx, ptr, size FLARG_PASS);
else
mctx->methods->memput(mctx, ptr, size FLARG_PASS);
} }
void void
isc__mem_putanddetach(isc_mem_t **mctxp, void *ptr, size_t size FLARG) { isc__mem_putanddetach(isc_mem_t **mctxp, void *ptr, size_t size FLARG) {
REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp)); REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp));
if (isc_bind9)
isc___mem_putanddetach(mctxp, ptr, size FLARG_PASS); isc___mem_putanddetach(mctxp, ptr, size FLARG_PASS);
else
(*mctxp)->methods->memputanddetach(mctxp, ptr, size FLARG_PASS);
/* /*
* XXX: We cannot always ensure *mctxp == NULL here * XXX: We cannot always ensure *mctxp == NULL here
@@ -2941,58 +2800,40 @@ void *
isc__mem_allocate(isc_mem_t *mctx, size_t size FLARG) { isc__mem_allocate(isc_mem_t *mctx, size_t size FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc___mem_allocate(mctx, size FLARG_PASS)); return (isc___mem_allocate(mctx, size FLARG_PASS));
return (mctx->methods->memallocate(mctx, size FLARG_PASS));
} }
void * void *
isc__mem_reallocate(isc_mem_t *mctx, void *ptr, size_t size FLARG) { isc__mem_reallocate(isc_mem_t *mctx, void *ptr, size_t size FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc___mem_reallocate(mctx, ptr, size FLARG_PASS)); return (isc___mem_reallocate(mctx, ptr, size FLARG_PASS));
return (mctx->methods->memreallocate(mctx, ptr, size FLARG_PASS));
} }
char * char *
isc__mem_strdup(isc_mem_t *mctx, const char *s FLARG) { isc__mem_strdup(isc_mem_t *mctx, const char *s FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc___mem_strdup(mctx, s FLARG_PASS)); return (isc___mem_strdup(mctx, s FLARG_PASS));
return (mctx->methods->memstrdup(mctx, s FLARG_PASS));
} }
void void
isc__mem_free(isc_mem_t *mctx, void *ptr FLARG) { isc__mem_free(isc_mem_t *mctx, void *ptr FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx)); REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
isc___mem_free(mctx, ptr FLARG_PASS); isc___mem_free(mctx, ptr FLARG_PASS);
else
mctx->methods->memfree(mctx, ptr FLARG_PASS);
} }
void * void *
isc__mempool_get(isc_mempool_t *mpctx FLARG) { isc__mempool_get(isc_mempool_t *mpctx FLARG) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx)); REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
return (isc___mempool_get(mpctx FLARG_PASS)); return (isc___mempool_get(mpctx FLARG_PASS));
return (mpctx->methods->get(mpctx FLARG_PASS));
} }
void void
isc__mempool_put(isc_mempool_t *mpctx, void *mem FLARG) { isc__mempool_put(isc_mempool_t *mpctx, void *mem FLARG) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx)); REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc___mempool_put(mpctx, mem FLARG_PASS); isc___mempool_put(mpctx, mem FLARG_PASS);
else
mpctx->methods->put(mpctx, mem FLARG_PASS);
} }

View File

@@ -68,29 +68,14 @@ isc_socketmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
isc_result_t isc_result_t
isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) { isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
isc_result_t result;
if (isc_bind9)
return (isc__socketmgr_create(mctx, managerp)); return (isc__socketmgr_create(mctx, managerp));
LOCK(&createlock);
REQUIRE(socketmgr_createfunc != NULL);
result = (*socketmgr_createfunc)(mctx, managerp);
UNLOCK(&createlock);
return (result);
} }
void void
isc_socketmgr_destroy(isc_socketmgr_t **managerp) { isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
REQUIRE(managerp != NULL && ISCAPI_SOCKETMGR_VALID(*managerp)); REQUIRE(managerp != NULL && ISCAPI_SOCKETMGR_VALID(*managerp));
if (isc_bind9)
isc__socketmgr_destroy(managerp); isc__socketmgr_destroy(managerp);
else
(*managerp)->methods->destroy(managerp);
ENSURE(*managerp == NULL); ENSURE(*managerp == NULL);
} }
@@ -101,10 +86,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
{ {
REQUIRE(ISCAPI_SOCKETMGR_VALID(manager)); REQUIRE(ISCAPI_SOCKETMGR_VALID(manager));
if (isc_bind9)
return (isc__socket_create(manager, pf, type, socketp)); return (isc__socket_create(manager, pf, type, socketp));
return (manager->methods->socketcreate(manager, pf, type, socketp));
} }
void void
@@ -112,10 +94,7 @@ isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp) {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
REQUIRE(socketp != NULL && *socketp == NULL); REQUIRE(socketp != NULL && *socketp == NULL);
if (isc_bind9)
isc__socket_attach(sock, socketp); isc__socket_attach(sock, socketp);
else
sock->methods->attach(sock, socketp);
ENSURE(*socketp == sock); ENSURE(*socketp == sock);
} }
@@ -124,10 +103,7 @@ void
isc_socket_detach(isc_socket_t **socketp) { isc_socket_detach(isc_socket_t **socketp) {
REQUIRE(socketp != NULL && ISCAPI_SOCKET_VALID(*socketp)); REQUIRE(socketp != NULL && ISCAPI_SOCKET_VALID(*socketp));
if (isc_bind9)
isc__socket_detach(socketp); isc__socket_detach(socketp);
else
(*socketp)->methods->detach(socketp);
ENSURE(*socketp == NULL); ENSURE(*socketp == NULL);
} }
@@ -138,10 +114,7 @@ isc_socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr,
{ {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_bind(sock, sockaddr, options)); return (isc__socket_bind(sock, sockaddr, options));
return (sock->methods->bind(sock, sockaddr, options));
} }
isc_result_t isc_result_t
@@ -151,12 +124,8 @@ isc_socket_sendto(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
{ {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_sendto(sock, region, task, return (isc__socket_sendto(sock, region, task,
action, arg, address, pktinfo)); action, arg, address, pktinfo));
return (sock->methods->sendto(sock, region, task, action, arg, address,
pktinfo));
} }
isc_result_t isc_result_t
@@ -165,10 +134,7 @@ isc_socket_connect(isc_socket_t *sock, const isc_sockaddr_t *addr,
{ {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_connect(sock, addr, task, action, arg)); return (isc__socket_connect(sock, addr, task, action, arg));
return (sock->methods->connect(sock, addr, task, action, arg));
} }
isc_result_t isc_result_t
@@ -177,58 +143,43 @@ isc_socket_recv(isc_socket_t *sock, isc_region_t *region, unsigned int minimum,
{ {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_recv(sock, region, minimum, return (isc__socket_recv(sock, region, minimum,
task, action, arg)); task, action, arg));
return (sock->methods->recv(sock, region, minimum, task, action, arg));
} }
void void
isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
isc__socket_cancel(sock, task, how); isc__socket_cancel(sock, task, how);
else
sock->methods->cancel(sock, task, how);
} }
isc_result_t isc_result_t
isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) { isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_getsockname(sock, addressp)); return (isc__socket_getsockname(sock, addressp));
return (sock->methods->getsockname(sock, addressp));
} }
void void
isc_socket_ipv6only(isc_socket_t *sock, bool yes) { isc_socket_ipv6only(isc_socket_t *sock, bool yes) {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
isc__socket_ipv6only(sock, yes); isc__socket_ipv6only(sock, yes);
else
sock->methods->ipv6only(sock, yes);
} }
void void
isc_socket_dscp(isc_socket_t *sock, isc_dscp_t dscp) { isc_socket_dscp(isc_socket_t *sock, isc_dscp_t dscp) {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
sock->methods->dscp(sock, dscp); isc__socket_dscp(sock, dscp);
} }
isc_sockettype_t isc_sockettype_t
isc_socket_gettype(isc_socket_t *sock) { isc_socket_gettype(isc_socket_t *sock) {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_gettype(sock)); return (isc__socket_gettype(sock));
return (sock->methods->gettype(sock));
} }
void void
@@ -247,14 +198,9 @@ isc_socket_fdwatchcreate(isc_socketmgr_t *manager, int fd, int flags,
{ {
REQUIRE(ISCAPI_SOCKETMGR_VALID(manager)); REQUIRE(ISCAPI_SOCKETMGR_VALID(manager));
if (isc_bind9)
return (isc__socket_fdwatchcreate(manager, fd, flags, return (isc__socket_fdwatchcreate(manager, fd, flags,
callback, cbarg, callback, cbarg,
task, socketp)); task, socketp));
return (manager->methods->fdwatchcreate(manager, fd, flags,
callback, cbarg, task,
socketp));
} }
isc_result_t isc_result_t
@@ -262,10 +208,7 @@ isc_socket_fdwatchpoke(isc_socket_t *sock, int flags)
{ {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_fdwatchpoke(sock, flags)); return (isc__socket_fdwatchpoke(sock, flags));
return (sock->methods->fdwatchpoke(sock, flags));
} }
isc_result_t isc_result_t
@@ -273,20 +216,14 @@ isc_socket_dup(isc_socket_t *sock, isc_socket_t **socketp) {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
REQUIRE(socketp != NULL && *socketp == NULL); REQUIRE(socketp != NULL && *socketp == NULL);
if (isc_bind9)
return (isc__socket_dup(sock, socketp)); return (isc__socket_dup(sock, socketp));
return (sock->methods->dup(sock, socketp));
} }
int int
isc_socket_getfd(isc_socket_t *sock) { isc_socket_getfd(isc_socket_t *sock) {
REQUIRE(ISCAPI_SOCKET_VALID(sock)); REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_getfd(sock)); return (isc__socket_getfd(sock));
return (sock->methods->getfd(sock));
} }
isc_result_t isc_result_t

View File

@@ -1887,30 +1887,15 @@ isc_result_t
isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers, isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
unsigned int default_quantum, isc_taskmgr_t **managerp) unsigned int default_quantum, isc_taskmgr_t **managerp)
{ {
isc_result_t result;
if (isc_bind9)
return (isc__taskmgr_create(mctx, workers, return (isc__taskmgr_create(mctx, workers,
default_quantum, managerp)); default_quantum, managerp));
LOCK(&createlock);
REQUIRE(taskmgr_createfunc != NULL);
result = (*taskmgr_createfunc)(mctx, workers, default_quantum,
managerp);
UNLOCK(&createlock);
return (result);
} }
void void
isc_taskmgr_destroy(isc_taskmgr_t **managerp) { isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
REQUIRE(managerp != NULL && ISCAPI_TASKMGR_VALID(*managerp)); REQUIRE(managerp != NULL && ISCAPI_TASKMGR_VALID(*managerp));
if (isc_bind9)
isc__taskmgr_destroy(managerp); isc__taskmgr_destroy(managerp);
else
(*managerp)->methods->destroy(managerp);
ENSURE(*managerp == NULL); ENSURE(*managerp == NULL);
} }
@@ -1919,20 +1904,14 @@ void
isc_taskmgr_setmode(isc_taskmgr_t *manager, isc_taskmgrmode_t mode) { isc_taskmgr_setmode(isc_taskmgr_t *manager, isc_taskmgrmode_t mode) {
REQUIRE(ISCAPI_TASKMGR_VALID(manager)); REQUIRE(ISCAPI_TASKMGR_VALID(manager));
if (isc_bind9)
isc__taskmgr_setmode(manager, mode); isc__taskmgr_setmode(manager, mode);
else
manager->methods->setmode(manager, mode);
} }
isc_taskmgrmode_t isc_taskmgrmode_t
isc_taskmgr_mode(isc_taskmgr_t *manager) { isc_taskmgr_mode(isc_taskmgr_t *manager) {
REQUIRE(ISCAPI_TASKMGR_VALID(manager)); REQUIRE(ISCAPI_TASKMGR_VALID(manager));
if (isc_bind9)
return (isc__taskmgr_mode(manager)); return (isc__taskmgr_mode(manager));
return (manager->methods->mode(manager));
} }
isc_result_t isc_result_t
@@ -1942,10 +1921,7 @@ isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
REQUIRE(ISCAPI_TASKMGR_VALID(manager)); REQUIRE(ISCAPI_TASKMGR_VALID(manager));
REQUIRE(taskp != NULL && *taskp == NULL); REQUIRE(taskp != NULL && *taskp == NULL);
if (isc_bind9)
return (isc__task_create(manager, quantum, taskp)); return (isc__task_create(manager, quantum, taskp));
return (manager->methods->taskcreate(manager, quantum, taskp));
} }
void void
@@ -1953,10 +1929,7 @@ isc_task_attach(isc_task_t *source, isc_task_t **targetp) {
REQUIRE(ISCAPI_TASK_VALID(source)); REQUIRE(ISCAPI_TASK_VALID(source));
REQUIRE(targetp != NULL && *targetp == NULL); REQUIRE(targetp != NULL && *targetp == NULL);
if (isc_bind9)
isc__task_attach(source, targetp); isc__task_attach(source, targetp);
else
source->methods->attach(source, targetp);
ENSURE(*targetp == source); ENSURE(*targetp == source);
} }
@@ -1965,10 +1938,7 @@ void
isc_task_detach(isc_task_t **taskp) { isc_task_detach(isc_task_t **taskp) {
REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp)); REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp));
if (isc_bind9)
isc__task_detach(taskp); isc__task_detach(taskp);
else
(*taskp)->methods->detach(taskp);
ENSURE(*taskp == NULL); ENSURE(*taskp == NULL);
} }
@@ -1978,12 +1948,7 @@ isc_task_send(isc_task_t *task, isc_event_t **eventp) {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
REQUIRE(eventp != NULL && *eventp != NULL); REQUIRE(eventp != NULL && *eventp != NULL);
if (isc_bind9)
isc__task_send(task, eventp); isc__task_send(task, eventp);
else {
task->methods->send(task, eventp);
ENSURE(*eventp == NULL);
}
} }
void void
@@ -1991,12 +1956,7 @@ isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp)); REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp));
REQUIRE(eventp != NULL && *eventp != NULL); REQUIRE(eventp != NULL && *eventp != NULL);
if (isc_bind9)
isc__task_sendanddetach(taskp, eventp); isc__task_sendanddetach(taskp, eventp);
else {
(*taskp)->methods->sendanddetach(taskp, eventp);
ENSURE(*eventp == NULL);
}
ENSURE(*taskp == NULL); ENSURE(*taskp == NULL);
} }
@@ -2007,10 +1967,7 @@ isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
{ {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
return (isc__task_unsend(task, sender, type, tag, events)); return (isc__task_unsend(task, sender, type, tag, events));
return (task->methods->unsend(task, sender, type, tag, events));
} }
isc_result_t isc_result_t
@@ -2018,27 +1975,18 @@ isc_task_onshutdown(isc_task_t *task, isc_taskaction_t action, void *arg)
{ {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
return (isc__task_onshutdown(task, action, arg)); return (isc__task_onshutdown(task, action, arg));
return (task->methods->onshutdown(task, action, arg));
} }
void void
isc_task_shutdown(isc_task_t *task) { isc_task_shutdown(isc_task_t *task) {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
isc__task_shutdown(task); isc__task_shutdown(task);
else
task->methods->shutdown(task);
} }
void void
isc_task_destroy(isc_task_t **taskp) { isc_task_destroy(isc_task_t **taskp) {
if (!isc_bind9)
return;
isc__task_destroy(taskp); isc__task_destroy(taskp);
} }
@@ -2046,10 +1994,7 @@ void
isc_task_setname(isc_task_t *task, const char *name, void *tag) { isc_task_setname(isc_task_t *task, const char *name, void *tag) {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
isc__task_setname(task, name, tag); isc__task_setname(task, name, tag);
else
task->methods->setname(task, name, tag);
} }
unsigned int unsigned int
@@ -2057,65 +2002,44 @@ isc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type, void *tag)
{ {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
return (isc__task_purge(task, sender, type, tag)); return (isc__task_purge(task, sender, type, tag));
return (task->methods->purgeevents(task, sender, type, tag));
} }
isc_result_t isc_result_t
isc_task_beginexclusive(isc_task_t *task) { isc_task_beginexclusive(isc_task_t *task) {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
return (isc__task_beginexclusive(task)); return (isc__task_beginexclusive(task));
return (task->methods->beginexclusive(task));
} }
void void
isc_task_endexclusive(isc_task_t *task) { isc_task_endexclusive(isc_task_t *task) {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
isc__task_endexclusive(task); isc__task_endexclusive(task);
else
task->methods->endexclusive(task);
} }
void void
isc_task_setprivilege(isc_task_t *task, bool priv) { isc_task_setprivilege(isc_task_t *task, bool priv) {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
isc__task_setprivilege(task, priv); isc__task_setprivilege(task, priv);
else
task->methods->setprivilege(task, priv);
} }
bool bool
isc_task_privilege(isc_task_t *task) { isc_task_privilege(isc_task_t *task) {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
return (isc__task_privilege(task)); return (isc__task_privilege(task));
return (task->methods->privilege(task));
} }
void void
isc_task_getcurrenttime(isc_task_t *task, isc_stdtime_t *t) { isc_task_getcurrenttime(isc_task_t *task, isc_stdtime_t *t) {
if (!isc_bind9)
return;
isc__task_getcurrenttime(task, t); isc__task_getcurrenttime(task, t);
} }
void void
isc_task_getcurrenttimex(isc_task_t *task, isc_time_t *t) { isc_task_getcurrenttimex(isc_task_t *task, isc_time_t *t) {
if (!isc_bind9)
return;
isc__task_getcurrenttimex(task, t); isc__task_getcurrenttimex(task, t);
} }
@@ -2129,8 +2053,5 @@ isc_task_purgerange(isc_task_t *task, void *sender, isc_eventtype_t first,
{ {
REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(ISCAPI_TASK_VALID(task));
if (isc_bind9)
return (isc__task_purgerange(task, sender, first, last, tag)); return (isc__task_purgerange(task, sender, first, last, tag));
return (task->methods->purgerange(task, sender, first, last, tag));
} }

View File

@@ -127,34 +127,6 @@ isc_timermgr_poke(isc_timermgr_t *manager0);
void void
isc__timermgr_destroy(isc_timermgr_t **managerp); isc__timermgr_destroy(isc_timermgr_t **managerp);
static struct isc__timermethods {
isc_timermethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *gettype;
} timermethods = {
{
isc__timer_attach,
isc__timer_detach,
isc__timer_reset,
isc__timer_touch
},
(void *)isc_timer_gettype
};
static struct isc__timermgrmethods {
isc_timermgrmethods_t methods;
void *poke; /* see above */
} timermgrmethods = {
{
isc__timermgr_destroy,
isc__timer_create
},
(void *)isc_timermgr_poke
};
static inline isc_result_t static inline isc_result_t
schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) { schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
isc_result_t result; isc_result_t result;
@@ -385,7 +357,6 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
ISC_LINK_INIT(timer, link); ISC_LINK_INIT(timer, link);
timer->common.impmagic = TIMER_MAGIC; timer->common.impmagic = TIMER_MAGIC;
timer->common.magic = ISCAPI_TIMER_MAGIC; timer->common.magic = ISCAPI_TIMER_MAGIC;
timer->common.methods = (isc_timermethods_t *)&timermethods;
LOCK(&manager->lock); LOCK(&manager->lock);
@@ -787,7 +758,6 @@ isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
manager->common.impmagic = TIMER_MANAGER_MAGIC; manager->common.impmagic = TIMER_MANAGER_MAGIC;
manager->common.magic = ISCAPI_TIMERMGR_MAGIC; manager->common.magic = ISCAPI_TIMERMGR_MAGIC;
manager->common.methods = (isc_timermgrmethods_t *)&timermgrmethods;
manager->mctx = NULL; manager->mctx = NULL;
manager->done = false; manager->done = false;
INIT_LIST(manager->timers); INIT_LIST(manager->timers);
@@ -947,29 +917,14 @@ isc_timermgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
isc_result_t 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_result_t result;
if (isc_bind9)
return (isc__timermgr_create(mctx, managerp)); return (isc__timermgr_create(mctx, managerp));
LOCK(&createlock);
REQUIRE(timermgr_createfunc != NULL);
result = (*timermgr_createfunc)(mctx, managerp);
UNLOCK(&createlock);
return (result);
} }
void void
isc_timermgr_destroy(isc_timermgr_t **managerp) { isc_timermgr_destroy(isc_timermgr_t **managerp) {
REQUIRE(*managerp != NULL && ISCAPI_TIMERMGR_VALID(*managerp)); REQUIRE(*managerp != NULL && ISCAPI_TIMERMGR_VALID(*managerp));
if (isc_bind9)
isc__timermgr_destroy(managerp); isc__timermgr_destroy(managerp);
else
(*managerp)->methods->destroy(managerp);
ENSURE(*managerp == NULL); ENSURE(*managerp == NULL);
} }
@@ -982,13 +937,8 @@ isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type,
{ {
REQUIRE(ISCAPI_TIMERMGR_VALID(manager)); REQUIRE(ISCAPI_TIMERMGR_VALID(manager));
if (isc_bind9)
return (isc__timer_create(manager, type, expires, interval, return (isc__timer_create(manager, type, expires, interval,
task, action, arg, timerp)); task, action, arg, timerp));
return (manager->methods->timercreate(manager, type, expires,
interval, task, action, arg,
timerp));
} }
void void
@@ -996,10 +946,7 @@ isc_timer_attach(isc_timer_t *timer, isc_timer_t **timerp) {
REQUIRE(ISCAPI_TIMER_VALID(timer)); REQUIRE(ISCAPI_TIMER_VALID(timer));
REQUIRE(timerp != NULL && *timerp == NULL); REQUIRE(timerp != NULL && *timerp == NULL);
if (isc_bind9)
isc__timer_attach(timer, timerp); isc__timer_attach(timer, timerp);
else
timer->methods->attach(timer, timerp);
ENSURE(*timerp == timer); ENSURE(*timerp == timer);
} }
@@ -1008,10 +955,7 @@ void
isc_timer_detach(isc_timer_t **timerp) { isc_timer_detach(isc_timer_t **timerp) {
REQUIRE(timerp != NULL && ISCAPI_TIMER_VALID(*timerp)); REQUIRE(timerp != NULL && ISCAPI_TIMER_VALID(*timerp));
if (isc_bind9)
isc__timer_detach(timerp); isc__timer_detach(timerp);
else
(*timerp)->methods->detach(timerp);
ENSURE(*timerp == NULL); ENSURE(*timerp == NULL);
} }
@@ -1023,19 +967,13 @@ isc_timer_reset(isc_timer_t *timer, isc_timertype_t type,
{ {
REQUIRE(ISCAPI_TIMER_VALID(timer)); REQUIRE(ISCAPI_TIMER_VALID(timer));
if (isc_bind9)
return (isc__timer_reset(timer, type, expires, return (isc__timer_reset(timer, type, expires,
interval, purge)); interval, purge));
return (timer->methods->reset(timer, type, expires, interval, purge));
} }
isc_result_t isc_result_t
isc_timer_touch(isc_timer_t *timer) { isc_timer_touch(isc_timer_t *timer) {
REQUIRE(ISCAPI_TIMER_VALID(timer)); REQUIRE(ISCAPI_TIMER_VALID(timer));
if (isc_bind9)
return (isc__timer_touch(timer)); return (isc__timer_touch(timer));
return (timer->methods->touch(timer));
} }

View File

@@ -115,35 +115,6 @@ typedef struct isc__appctx {
static isc__appctx_t isc_g_appctx; static isc__appctx_t isc_g_appctx;
static struct {
isc_appmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *run, *shutdown, *start, *reload, *finish, *block, *unblock;
} appmethods = {
{
isc__appctx_destroy,
isc__app_ctxstart,
isc__app_ctxrun,
isc__app_ctxsuspend,
isc__app_ctxshutdown,
isc__app_ctxfinish,
isc__appctx_settaskmgr,
isc__appctx_setsocketmgr,
isc__appctx_settimermgr,
isc__app_ctxonrun
},
(void *)isc__app_run,
(void *)isc__app_shutdown,
(void *)isc__app_start,
(void *)isc__app_reload,
(void *)isc__app_finish,
(void *)isc__app_block,
(void *)isc__app_unblock
};
#ifndef HAVE_SIGWAIT #ifndef HAVE_SIGWAIT
static void static void
exit_action(int arg) { exit_action(int arg) {
@@ -302,7 +273,6 @@ isc_result_t
isc__app_start(void) { isc__app_start(void) {
isc_g_appctx.common.impmagic = APPCTX_MAGIC; isc_g_appctx.common.impmagic = APPCTX_MAGIC;
isc_g_appctx.common.magic = ISCAPI_APPCTX_MAGIC; isc_g_appctx.common.magic = ISCAPI_APPCTX_MAGIC;
isc_g_appctx.common.methods = &appmethods.methods;
isc_g_appctx.mctx = NULL; isc_g_appctx.mctx = NULL;
/* The remaining members will be initialized in ctxstart() */ /* The remaining members will be initialized in ctxstart() */
@@ -674,7 +644,6 @@ isc__appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
ctx->common.impmagic = APPCTX_MAGIC; ctx->common.impmagic = APPCTX_MAGIC;
ctx->common.magic = ISCAPI_APPCTX_MAGIC; ctx->common.magic = ISCAPI_APPCTX_MAGIC;
ctx->common.methods = &appmethods.methods;
ctx->mctx = NULL; ctx->mctx = NULL;
isc_mem_attach(mctx, &ctx->mctx); isc_mem_attach(mctx, &ctx->mctx);

View File

@@ -606,47 +606,6 @@ isc_result_t
isc__socketmgr_renderjson(isc_socketmgr_t *mgr0, json_object *stats); isc__socketmgr_renderjson(isc_socketmgr_t *mgr0, json_object *stats);
#endif #endif
static struct {
isc_socketmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *recvv, *send, *sendv, *sendto2, *cleanunix, *permunix, *filter,
*listen, *accept, *getpeername, *isbound;
} socketmethods = {
{
isc__socket_attach,
isc__socket_detach,
isc__socket_bind,
isc__socket_sendto,
isc__socket_sendto2,
isc__socket_connect,
isc__socket_recv,
isc__socket_recv2,
isc__socket_cancel,
isc__socket_getsockname,
isc__socket_gettype,
isc__socket_ipv6only,
isc__socket_fdwatchpoke,
isc__socket_dup,
isc__socket_getfd,
isc__socket_dscp
},
(void *)isc__socket_recvv, (void *)isc__socket_send,
(void *)isc__socket_sendv, (void *)isc__socket_sendto2,
(void *)isc__socket_cleanunix, (void *)isc__socket_permunix,
(void *)isc__socket_filter, (void *)isc__socket_listen,
(void *)isc__socket_accept, (void *)isc__socket_getpeername,
(void *)isc__socket_isbound
};
static isc_socketmgrmethods_t socketmgrmethods = {
isc__socketmgr_destroy,
isc__socket_create,
isc__socket_fdwatchcreate
};
#define SELECT_POKE_SHUTDOWN (-1) #define SELECT_POKE_SHUTDOWN (-1)
#define SELECT_POKE_NOTHING (-2) #define SELECT_POKE_NOTHING (-2)
#define SELECT_POKE_READ (-3) #define SELECT_POKE_READ (-3)
@@ -2892,7 +2851,6 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
return (result); return (result);
} }
sock->common.methods = (isc_socketmethods_t *)&socketmethods;
sock->references = 1; sock->references = 1;
*socketp = (isc_socket_t *)sock; *socketp = (isc_socket_t *)sock;
@@ -3037,7 +2995,6 @@ isc__socket_fdwatchcreate(isc_socketmgr_t *manager0, int fd, int flags,
sock->fdwatchtask = task; sock->fdwatchtask = task;
sock->statsindex = fdwatchstatsindex; sock->statsindex = fdwatchstatsindex;
sock->common.methods = (isc_socketmethods_t *)&socketmethods;
sock->references = 1; sock->references = 1;
*socketp = (isc_socket_t *)sock; *socketp = (isc_socket_t *)sock;
@@ -4537,7 +4494,6 @@ isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
#endif #endif
manager->stats = NULL; manager->stats = NULL;
manager->common.methods = &socketmgrmethods;
manager->common.magic = ISCAPI_SOCKETMGR_MAGIC; manager->common.magic = ISCAPI_SOCKETMGR_MAGIC;
manager->common.impmagic = SOCKET_MANAGER_MAGIC; manager->common.impmagic = SOCKET_MANAGER_MAGIC;
manager->mctx = NULL; manager->mctx = NULL;