mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 05:57:52 +00:00
Cleanup the public vs private ISCAPI remnants
Since all the libraries are internal now, just cleanup the ISCAPI remnants in isc_socket, isc_task and isc_timer APIs. This means, there's one less layer as following changes have been done: * struct isc_socket and struct isc_socketmgr have been removed * struct isc__socket and struct isc__socketmgr have been renamed to struct isc_socket and struct isc_socketmgr * struct isc_task and struct isc_taskmgr have been removed * struct isc__task and struct isc__taskmgr have been renamed to struct isc_task and struct isc_taskmgr * struct isc_timer and struct isc_timermgr have been removed * struct isc__timer and struct isc__timermgr have been renamed to struct isc_timer and struct isc_timermgr * All the associated code that dealt with typing isc_<foo> to isc__<foo> and back has been removed.
This commit is contained in:
parent
5937c1f787
commit
16fe0d1f41
@ -93,17 +93,6 @@ typedef isc_event_t isc_appevent_t;
|
||||
#define ISC_APPEVENT_SHUTDOWN (ISC_EVENTCLASS_APP + 1)
|
||||
#define ISC_APPEVENT_LASTEVENT (ISC_EVENTCLASS_APP + 65535)
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of an application context
|
||||
* implementation's version of an isc_appctx_t.
|
||||
* \brief
|
||||
* Direct use of this structure by clients is forbidden. app implementations
|
||||
* may change the structure. 'magic' must be ISCAPI_APPCTX_MAGIC for any
|
||||
* of the isc_app_ routines to work. app implementations must maintain
|
||||
* all app context invariants.
|
||||
*/
|
||||
struct isc_appctx;
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
|
@ -191,45 +191,6 @@ typedef enum {
|
||||
#define ISC_SOCKFLAG_NORETRY 0x00000002 /*%< drop failed UDP sends */
|
||||
/*@}*/
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of a socket manager
|
||||
* object implementation's version of an isc_socketmgr_t.
|
||||
* \brief
|
||||
* Direct use of this structure by clients is forbidden. socket implementations
|
||||
* may change the structure. 'magic' must be ISCAPI_SOCKETMGR_MAGIC for any
|
||||
* of the isc_socket_ routines to work. socket implementations must maintain
|
||||
* all socket invariants.
|
||||
* In effect, this definition is used only for non-BIND9 version ("export")
|
||||
* of the library, and the export version does not work for win32. So, to avoid
|
||||
* the definition conflict with win32/socket.c, we enable this definition only
|
||||
* for non-Win32 (i.e. Unix) platforms.
|
||||
*/
|
||||
#ifndef WIN32
|
||||
struct isc_socketmgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
};
|
||||
#endif /* ifndef WIN32 */
|
||||
|
||||
#define ISCAPI_SOCKETMGR_MAGIC ISC_MAGIC('A', 's', 'm', 'g')
|
||||
#define ISCAPI_SOCKETMGR_VALID(m) \
|
||||
((m) != NULL && (m)->magic == ISCAPI_SOCKETMGR_MAGIC)
|
||||
|
||||
/*%
|
||||
* This is the common prefix of a socket object. The same note as
|
||||
* that for the socketmgr structure applies.
|
||||
*/
|
||||
#ifndef WIN32
|
||||
struct isc_socket {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
};
|
||||
#endif /* ifndef WIN32 */
|
||||
|
||||
#define ISCAPI_SOCKET_MAGIC ISC_MAGIC('A', 's', 'c', 't')
|
||||
#define ISCAPI_SOCKET_VALID(s) \
|
||||
((s) != NULL && (s)->magic == ISCAPI_SOCKET_MAGIC)
|
||||
|
||||
/***
|
||||
*** Socket and Socket Manager Functions
|
||||
***
|
||||
|
@ -99,36 +99,6 @@ typedef enum {
|
||||
isc_taskmgrmode_privileged
|
||||
} isc_taskmgrmode_t;
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of a task manager
|
||||
* object implementation's version of an isc_taskmgr_t.
|
||||
* \brief
|
||||
* Direct use of this structure by clients is forbidden. task implementations
|
||||
* may change the structure. 'magic' must be ISCAPI_TASKMGR_MAGIC for any
|
||||
* of the isc_task_ routines to work. task implementations must maintain
|
||||
* all task invariants.
|
||||
*/
|
||||
struct isc_taskmgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
};
|
||||
|
||||
#define ISCAPI_TASKMGR_MAGIC ISC_MAGIC('A', 't', 'm', 'g')
|
||||
#define ISCAPI_TASKMGR_VALID(m) \
|
||||
((m) != NULL && (m)->magic == ISCAPI_TASKMGR_MAGIC)
|
||||
|
||||
/*%
|
||||
* This is the common prefix of a task object. The same note as
|
||||
* that for the taskmgr structure applies.
|
||||
*/
|
||||
struct isc_task {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
};
|
||||
|
||||
#define ISCAPI_TASK_MAGIC ISC_MAGIC('A', 't', 's', 't')
|
||||
#define ISCAPI_TASK_VALID(s) ((s) != NULL && (s)->magic == ISCAPI_TASK_MAGIC)
|
||||
|
||||
isc_result_t
|
||||
isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
|
||||
isc_task_t **taskp);
|
||||
|
@ -97,36 +97,6 @@ typedef struct isc_timerevent {
|
||||
#define ISC_TIMEREVENT_LIFE (ISC_EVENTCLASS_TIMER + 3)
|
||||
#define ISC_TIMEREVENT_LASTEVENT (ISC_EVENTCLASS_TIMER + 65535)
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of a timer manager
|
||||
* object implementation's version of an isc_timermgr_t.
|
||||
* \brief
|
||||
* Direct use of this structure by clients is forbidden. timer implementations
|
||||
* may change the structure. 'magic' must be ISCAPI_TIMERMGR_MAGIC for any
|
||||
* of the isc_timer_ routines to work. timer implementations must maintain
|
||||
* all timer invariants.
|
||||
*/
|
||||
struct isc_timermgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
};
|
||||
|
||||
#define ISCAPI_TIMERMGR_MAGIC ISC_MAGIC('A', 't', 'm', 'g')
|
||||
#define ISCAPI_TIMERMGR_VALID(m) \
|
||||
((m) != NULL && (m)->magic == ISCAPI_TIMERMGR_MAGIC)
|
||||
|
||||
/*%
|
||||
* This is the common prefix of a timer object. The same note as
|
||||
* that for the timermgr structure applies.
|
||||
*/
|
||||
struct isc_timer {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
};
|
||||
|
||||
#define ISCAPI_TIMER_MAGIC ISC_MAGIC('A', 't', 'm', 'r')
|
||||
#define ISCAPI_TIMER_VALID(s) ((s) != NULL && (s)->magic == ISCAPI_TIMER_MAGIC)
|
||||
|
||||
/***
|
||||
*** Timer and Timer Manager Functions
|
||||
***
|
||||
|
223
lib/isc/task.c
223
lib/isc/task.c
@ -97,14 +97,12 @@ static const char *statenames[] = {
|
||||
#define TASK_MAGIC ISC_MAGIC('T', 'A', 'S', 'K')
|
||||
#define VALID_TASK(t) ISC_MAGIC_VALID(t, TASK_MAGIC)
|
||||
|
||||
typedef struct isc__task isc__task_t;
|
||||
typedef struct isc__taskmgr isc__taskmgr_t;
|
||||
typedef struct isc__taskqueue isc__taskqueue_t;
|
||||
|
||||
struct isc__task {
|
||||
struct isc_task {
|
||||
/* Not locked. */
|
||||
isc_task_t common;
|
||||
isc__taskmgr_t *manager;
|
||||
unsigned int magic;
|
||||
isc_taskmgr_t *manager;
|
||||
isc_mutex_t lock;
|
||||
/* Locked by task lock. */
|
||||
task_state_t state;
|
||||
@ -123,9 +121,9 @@ struct isc__task {
|
||||
/* Protected by atomics */
|
||||
atomic_uint_fast32_t flags;
|
||||
/* Locked by task manager lock. */
|
||||
LINK(isc__task_t) link;
|
||||
LINK(isc__task_t) ready_link;
|
||||
LINK(isc__task_t) ready_priority_link;
|
||||
LINK(isc_task_t) link;
|
||||
LINK(isc_task_t) ready_link;
|
||||
LINK(isc_task_t) ready_priority_link;
|
||||
};
|
||||
|
||||
#define TASK_F_SHUTTINGDOWN 0x01
|
||||
@ -142,7 +140,7 @@ struct isc__task {
|
||||
#define TASK_MANAGER_MAGIC ISC_MAGIC('T', 'S', 'K', 'M')
|
||||
#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, TASK_MANAGER_MAGIC)
|
||||
|
||||
typedef ISC_LIST(isc__task_t) isc__tasklist_t;
|
||||
typedef ISC_LIST(isc_task_t) isc__tasklist_t;
|
||||
|
||||
struct isc__taskqueue {
|
||||
/* Everything locked by lock */
|
||||
@ -152,12 +150,12 @@ struct isc__taskqueue {
|
||||
isc_condition_t work_available;
|
||||
isc_thread_t thread;
|
||||
unsigned int threadid;
|
||||
isc__taskmgr_t *manager;
|
||||
isc_taskmgr_t *manager;
|
||||
};
|
||||
|
||||
struct isc__taskmgr {
|
||||
struct isc_taskmgr {
|
||||
/* Not locked. */
|
||||
isc_taskmgr_t common;
|
||||
unsigned int magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_mutex_t lock;
|
||||
isc_mutex_t halt_lock;
|
||||
@ -172,7 +170,7 @@ struct isc__taskmgr {
|
||||
|
||||
/* Locked by task manager lock. */
|
||||
unsigned int default_quantum;
|
||||
LIST(isc__task_t) tasks;
|
||||
LIST(isc_task_t) tasks;
|
||||
atomic_uint_fast32_t mode;
|
||||
atomic_bool pause_req;
|
||||
atomic_bool exclusive_req;
|
||||
@ -187,7 +185,7 @@ struct isc__taskmgr {
|
||||
* will try to acquire it.
|
||||
*/
|
||||
isc_mutex_t excl_lock;
|
||||
isc__task_t *excl;
|
||||
isc_task_t *excl;
|
||||
};
|
||||
|
||||
void
|
||||
@ -207,29 +205,29 @@ isc__taskmgr_resume(isc_taskmgr_t *manager0);
|
||||
*/
|
||||
|
||||
bool
|
||||
isc_task_purgeevent(isc_task_t *task0, isc_event_t *event);
|
||||
isc_task_purgeevent(isc_task_t *task, isc_event_t *event);
|
||||
void
|
||||
isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0);
|
||||
isc_taskmgr_setexcltask(isc_taskmgr_t *mgr, isc_task_t *task);
|
||||
isc_result_t
|
||||
isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp);
|
||||
isc_taskmgr_excltask(isc_taskmgr_t *mgr, isc_task_t **taskp);
|
||||
static inline bool
|
||||
empty_readyq(isc__taskmgr_t *manager, int c);
|
||||
empty_readyq(isc_taskmgr_t *manager, int c);
|
||||
|
||||
static inline isc__task_t *
|
||||
pop_readyq(isc__taskmgr_t *manager, int c);
|
||||
static inline isc_task_t *
|
||||
pop_readyq(isc_taskmgr_t *manager, int c);
|
||||
|
||||
static inline void
|
||||
push_readyq(isc__taskmgr_t *manager, isc__task_t *task, int c);
|
||||
push_readyq(isc_taskmgr_t *manager, isc_task_t *task, int c);
|
||||
|
||||
static inline void
|
||||
wake_all_queues(isc__taskmgr_t *manager);
|
||||
wake_all_queues(isc_taskmgr_t *manager);
|
||||
|
||||
/***
|
||||
*** Tasks.
|
||||
***/
|
||||
|
||||
static inline void
|
||||
wake_all_queues(isc__taskmgr_t *manager) {
|
||||
wake_all_queues(isc_taskmgr_t *manager) {
|
||||
for (unsigned int i = 0; i < manager->workers; i++) {
|
||||
LOCK(&manager->queues[i].lock);
|
||||
BROADCAST(&manager->queues[i].work_available);
|
||||
@ -238,8 +236,8 @@ wake_all_queues(isc__taskmgr_t *manager) {
|
||||
}
|
||||
|
||||
static void
|
||||
task_finished(isc__task_t *task) {
|
||||
isc__taskmgr_t *manager = task->manager;
|
||||
task_finished(isc_task_t *task) {
|
||||
isc_taskmgr_t *manager = task->manager;
|
||||
REQUIRE(EMPTY(task->events));
|
||||
REQUIRE(task->nevents == 0);
|
||||
REQUIRE(EMPTY(task->on_shutdown));
|
||||
@ -263,8 +261,7 @@ task_finished(isc__task_t *task) {
|
||||
wake_all_queues(manager);
|
||||
}
|
||||
isc_mutex_destroy(&task->lock);
|
||||
task->common.impmagic = 0;
|
||||
task->common.magic = 0;
|
||||
task->magic = 0;
|
||||
isc_mem_put(manager->mctx, task, sizeof(*task));
|
||||
}
|
||||
|
||||
@ -277,8 +274,8 @@ isc_task_create(isc_taskmgr_t *manager0, unsigned int quantum,
|
||||
isc_result_t
|
||||
isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum,
|
||||
isc_task_t **taskp, int threadid) {
|
||||
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
|
||||
isc__task_t *task;
|
||||
isc_taskmgr_t *manager = (isc_taskmgr_t *)manager0;
|
||||
isc_task_t *task;
|
||||
bool exiting;
|
||||
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
@ -339,17 +336,14 @@ isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum,
|
||||
return (ISC_R_SHUTTINGDOWN);
|
||||
}
|
||||
|
||||
task->common.magic = ISCAPI_TASK_MAGIC;
|
||||
task->common.impmagic = TASK_MAGIC;
|
||||
*taskp = (isc_task_t *)task;
|
||||
task->magic = TASK_MAGIC;
|
||||
*taskp = task;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_attach(isc_task_t *source0, isc_task_t **targetp) {
|
||||
isc__task_t *source = (isc__task_t *)source0;
|
||||
|
||||
isc_task_attach(isc_task_t *source, isc_task_t **targetp) {
|
||||
/*
|
||||
* Attach *targetp to source.
|
||||
*/
|
||||
@ -361,11 +355,11 @@ isc_task_attach(isc_task_t *source0, isc_task_t **targetp) {
|
||||
|
||||
isc_refcount_increment(&source->references);
|
||||
|
||||
*targetp = (isc_task_t *)source;
|
||||
*targetp = source;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
task_shutdown(isc__task_t *task) {
|
||||
task_shutdown(isc_task_t *task) {
|
||||
bool was_idle = false;
|
||||
isc_event_t *event, *prev;
|
||||
|
||||
@ -409,9 +403,9 @@ task_shutdown(isc__task_t *task) {
|
||||
* Caller must NOT hold queue lock.
|
||||
*/
|
||||
static inline void
|
||||
task_ready(isc__task_t *task) {
|
||||
isc__taskmgr_t *manager = task->manager;
|
||||
bool has_privilege = isc_task_privilege((isc_task_t *)task);
|
||||
task_ready(isc_task_t *task) {
|
||||
isc_taskmgr_t *manager = task->manager;
|
||||
bool has_privilege = isc_task_privilege(task);
|
||||
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
@ -426,7 +420,7 @@ task_ready(isc__task_t *task) {
|
||||
}
|
||||
|
||||
static inline bool
|
||||
task_detach(isc__task_t *task) {
|
||||
task_detach(isc_task_t *task) {
|
||||
/*
|
||||
* Caller must be holding the task lock.
|
||||
*/
|
||||
@ -454,7 +448,7 @@ task_detach(isc__task_t *task) {
|
||||
|
||||
void
|
||||
isc_task_detach(isc_task_t **taskp) {
|
||||
isc__task_t *task;
|
||||
isc_task_t *task;
|
||||
bool was_idle;
|
||||
|
||||
/*
|
||||
@ -462,7 +456,7 @@ isc_task_detach(isc_task_t **taskp) {
|
||||
*/
|
||||
|
||||
REQUIRE(taskp != NULL);
|
||||
task = (isc__task_t *)*taskp;
|
||||
task = *taskp;
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
XTRACE("isc_task_detach");
|
||||
@ -479,7 +473,7 @@ isc_task_detach(isc_task_t **taskp) {
|
||||
}
|
||||
|
||||
static inline bool
|
||||
task_send(isc__task_t *task, isc_event_t **eventp, int c) {
|
||||
task_send(isc_task_t *task, isc_event_t **eventp, int c) {
|
||||
bool was_idle = false;
|
||||
isc_event_t *event;
|
||||
|
||||
@ -514,8 +508,8 @@ task_send(isc__task_t *task, isc_event_t **eventp, int c) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_send(isc_task_t *task0, isc_event_t **eventp) {
|
||||
isc_task_sendto(task0, eventp, -1);
|
||||
isc_task_send(isc_task_t *task, isc_event_t **eventp) {
|
||||
isc_task_sendto(task, eventp, -1);
|
||||
}
|
||||
|
||||
void
|
||||
@ -524,8 +518,7 @@ isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc_task_sendto(isc_task_t *task, isc_event_t **eventp, int c) {
|
||||
bool was_idle;
|
||||
|
||||
/*
|
||||
@ -575,7 +568,7 @@ isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) {
|
||||
void
|
||||
isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) {
|
||||
bool idle1, idle2;
|
||||
isc__task_t *task;
|
||||
isc_task_t *task;
|
||||
|
||||
/*
|
||||
* Send '*event' to '*taskp' and then detach '*taskp' from its
|
||||
@ -583,7 +576,7 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) {
|
||||
*/
|
||||
|
||||
REQUIRE(taskp != NULL);
|
||||
task = (isc__task_t *)*taskp;
|
||||
task = *taskp;
|
||||
REQUIRE(VALID_TASK(task));
|
||||
XTRACE("isc_task_sendanddetach");
|
||||
|
||||
@ -616,7 +609,7 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) {
|
||||
#define PURGE_OK(event) (((event)->ev_attributes & ISC_EVENTATTR_NOPURGE) == 0)
|
||||
|
||||
static unsigned int
|
||||
dequeue_events(isc__task_t *task, void *sender, isc_eventtype_t first,
|
||||
dequeue_events(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
isc_eventtype_t last, void *tag, isc_eventlist_t *events,
|
||||
bool purging) {
|
||||
isc_event_t *event, *next_event;
|
||||
@ -657,9 +650,8 @@ dequeue_events(isc__task_t *task, void *sender, isc_eventtype_t first,
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc_task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
|
||||
isc_task_purgerange(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
isc_eventtype_t last, void *tag) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
unsigned int count;
|
||||
isc_eventlist_t events;
|
||||
isc_event_t *event, *next_event;
|
||||
@ -702,8 +694,7 @@ isc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
}
|
||||
|
||||
bool
|
||||
isc_task_purgeevent(isc_task_t *task0, isc_event_t *event) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc_task_purgeevent(isc_task_t *task, isc_event_t *event) {
|
||||
isc_event_t *curr_event, *next_event;
|
||||
|
||||
/*
|
||||
@ -756,7 +747,7 @@ isc_task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
|
||||
XTRACE("isc_task_unsendrange");
|
||||
|
||||
return (dequeue_events((isc__task_t *)task, sender, first, last, tag,
|
||||
return (dequeue_events((isc_task_t *)task, sender, first, last, tag,
|
||||
events, false));
|
||||
}
|
||||
|
||||
@ -769,13 +760,12 @@ isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type, void *tag,
|
||||
|
||||
XTRACE("isc_task_unsend");
|
||||
|
||||
return (dequeue_events((isc__task_t *)task, sender, type, type, tag,
|
||||
return (dequeue_events((isc_task_t *)task, sender, type, type, tag,
|
||||
events, false));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_task_onshutdown(isc_task_t *task0, isc_taskaction_t action, void *arg) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc_task_onshutdown(isc_task_t *task, isc_taskaction_t action, void *arg) {
|
||||
bool disallowed = false;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_event_t *event;
|
||||
@ -809,8 +799,7 @@ isc_task_onshutdown(isc_task_t *task0, isc_taskaction_t action, void *arg) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_shutdown(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc_task_shutdown(isc_task_t *task) {
|
||||
bool was_idle;
|
||||
|
||||
/*
|
||||
@ -841,9 +830,7 @@ isc_task_destroy(isc_task_t **taskp) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_setname(isc_task_t *task0, const char *name, void *tag) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
isc_task_setname(isc_task_t *task, const char *name, void *tag) {
|
||||
/*
|
||||
* Name 'task'.
|
||||
*/
|
||||
@ -857,27 +844,21 @@ isc_task_setname(isc_task_t *task0, const char *name, void *tag) {
|
||||
}
|
||||
|
||||
const char *
|
||||
isc_task_getname(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
isc_task_getname(isc_task_t *task) {
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
return (task->name);
|
||||
}
|
||||
|
||||
void *
|
||||
isc_task_gettag(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
isc_task_gettag(isc_task_t *task) {
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
return (task->tag);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
isc_task_getcurrenttime(isc_task_t *task, isc_stdtime_t *t) {
|
||||
REQUIRE(VALID_TASK(task));
|
||||
REQUIRE(t != NULL);
|
||||
|
||||
@ -887,9 +868,7 @@ isc_task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_getcurrenttimex(isc_task_t *task0, isc_time_t *t) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
isc_task_getcurrenttimex(isc_task_t *task, isc_time_t *t) {
|
||||
REQUIRE(VALID_TASK(task));
|
||||
REQUIRE(t != NULL);
|
||||
|
||||
@ -910,7 +889,7 @@ isc_task_getcurrenttimex(isc_task_t *task0, isc_time_t *t) {
|
||||
* Caller must hold the task manager lock.
|
||||
*/
|
||||
static inline bool
|
||||
empty_readyq(isc__taskmgr_t *manager, int c) {
|
||||
empty_readyq(isc_taskmgr_t *manager, int c) {
|
||||
isc__tasklist_t queue;
|
||||
|
||||
if (atomic_load_relaxed(&manager->mode) == isc_taskmgrmode_normal) {
|
||||
@ -929,9 +908,9 @@ empty_readyq(isc__taskmgr_t *manager, int c) {
|
||||
*
|
||||
* Caller must hold the task manager lock.
|
||||
*/
|
||||
static inline isc__task_t *
|
||||
pop_readyq(isc__taskmgr_t *manager, int c) {
|
||||
isc__task_t *task;
|
||||
static inline isc_task_t *
|
||||
pop_readyq(isc_taskmgr_t *manager, int c) {
|
||||
isc_task_t *task;
|
||||
|
||||
if (atomic_load_relaxed(&manager->mode) == isc_taskmgrmode_normal) {
|
||||
task = HEAD(manager->queues[c].ready_tasks);
|
||||
@ -957,7 +936,7 @@ pop_readyq(isc__taskmgr_t *manager, int c) {
|
||||
* Caller must hold the task queue lock.
|
||||
*/
|
||||
static inline void
|
||||
push_readyq(isc__taskmgr_t *manager, isc__task_t *task, int c) {
|
||||
push_readyq(isc_taskmgr_t *manager, isc_task_t *task, int c) {
|
||||
if (ISC_LINK_LINKED(task, ready_link)) {
|
||||
return;
|
||||
}
|
||||
@ -971,8 +950,8 @@ push_readyq(isc__taskmgr_t *manager, isc__task_t *task, int c) {
|
||||
}
|
||||
|
||||
static void
|
||||
dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
|
||||
isc__task_t *task;
|
||||
dispatch(isc_taskmgr_t *manager, unsigned int threadid) {
|
||||
isc_task_t *task;
|
||||
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
@ -1336,7 +1315,7 @@ static isc_threadresult_t
|
||||
#endif /* ifdef _WIN32 */
|
||||
run(void *queuep) {
|
||||
isc__taskqueue_t *tq = queuep;
|
||||
isc__taskmgr_t *manager = tq->manager;
|
||||
isc_taskmgr_t *manager = tq->manager;
|
||||
int threadid = tq->threadid;
|
||||
isc_thread_setaffinity(threadid);
|
||||
|
||||
@ -1354,7 +1333,7 @@ static isc_threadresult_t
|
||||
}
|
||||
|
||||
static void
|
||||
manager_free(isc__taskmgr_t *manager) {
|
||||
manager_free(isc_taskmgr_t *manager) {
|
||||
for (unsigned int i = 0; i < manager->workers; i++) {
|
||||
isc_mutex_destroy(&manager->queues[i].lock);
|
||||
isc_condition_destroy(&manager->queues[i].work_available);
|
||||
@ -1365,8 +1344,7 @@ manager_free(isc__taskmgr_t *manager) {
|
||||
isc_condition_destroy(&manager->halt_cond);
|
||||
isc_mem_put(manager->mctx, manager->queues,
|
||||
manager->workers * sizeof(isc__taskqueue_t));
|
||||
manager->common.impmagic = 0;
|
||||
manager->common.magic = 0;
|
||||
manager->magic = 0;
|
||||
isc_mem_putanddetach(&manager->mctx, manager, sizeof(*manager));
|
||||
}
|
||||
|
||||
@ -1375,7 +1353,7 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
unsigned int default_quantum, isc_nm_t *nm,
|
||||
isc_taskmgr_t **managerp) {
|
||||
unsigned int i;
|
||||
isc__taskmgr_t *manager;
|
||||
isc_taskmgr_t *manager;
|
||||
|
||||
/*
|
||||
* Create a new task manager.
|
||||
@ -1385,8 +1363,7 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
REQUIRE(managerp != NULL && *managerp == NULL);
|
||||
|
||||
manager = isc_mem_get(mctx, sizeof(*manager));
|
||||
*manager = (isc__taskmgr_t){ .common.impmagic = TASK_MANAGER_MAGIC,
|
||||
.common.magic = ISCAPI_TASKMGR_MAGIC };
|
||||
*manager = (isc_taskmgr_t){ .magic = TASK_MANAGER_MAGIC };
|
||||
|
||||
atomic_store(&manager->mode, isc_taskmgrmode_normal);
|
||||
isc_mutex_init(&manager->lock);
|
||||
@ -1449,8 +1426,8 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
|
||||
void
|
||||
isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
|
||||
isc__taskmgr_t *manager;
|
||||
isc__task_t *task;
|
||||
isc_taskmgr_t *manager;
|
||||
isc_task_t *task;
|
||||
unsigned int i;
|
||||
bool exiting;
|
||||
|
||||
@ -1459,7 +1436,7 @@ isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
|
||||
*/
|
||||
|
||||
REQUIRE(managerp != NULL);
|
||||
manager = (isc__taskmgr_t *)*managerp;
|
||||
manager = (isc_taskmgr_t *)*managerp;
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
XTHREADTRACE("isc_taskmgr_destroy");
|
||||
@ -1549,20 +1526,20 @@ isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
|
||||
|
||||
void
|
||||
isc_taskmgr_setprivilegedmode(isc_taskmgr_t *manager0) {
|
||||
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
|
||||
isc_taskmgr_t *manager = (isc_taskmgr_t *)manager0;
|
||||
|
||||
atomic_store(&manager->mode, isc_taskmgrmode_privileged);
|
||||
}
|
||||
|
||||
isc_taskmgrmode_t
|
||||
isc_taskmgr_mode(isc_taskmgr_t *manager0) {
|
||||
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
|
||||
isc_taskmgr_t *manager = (isc_taskmgr_t *)manager0;
|
||||
return (atomic_load(&manager->mode));
|
||||
}
|
||||
|
||||
void
|
||||
isc__taskmgr_pause(isc_taskmgr_t *manager0) {
|
||||
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
|
||||
isc_taskmgr_t *manager = (isc_taskmgr_t *)manager0;
|
||||
|
||||
LOCK(&manager->halt_lock);
|
||||
while (atomic_load_relaxed(&manager->exclusive_req) ||
|
||||
@ -1584,7 +1561,7 @@ isc__taskmgr_pause(isc_taskmgr_t *manager0) {
|
||||
|
||||
void
|
||||
isc__taskmgr_resume(isc_taskmgr_t *manager0) {
|
||||
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
|
||||
isc_taskmgr_t *manager = (isc_taskmgr_t *)manager0;
|
||||
LOCK(&manager->halt_lock);
|
||||
if (atomic_load(&manager->pause_req)) {
|
||||
atomic_store(&manager->pause_req, false);
|
||||
@ -1597,23 +1574,19 @@ isc__taskmgr_resume(isc_taskmgr_t *manager0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0) {
|
||||
isc__taskmgr_t *mgr = (isc__taskmgr_t *)mgr0;
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
|
||||
isc_taskmgr_setexcltask(isc_taskmgr_t *mgr, isc_task_t *task) {
|
||||
REQUIRE(VALID_MANAGER(mgr));
|
||||
REQUIRE(VALID_TASK(task));
|
||||
LOCK(&mgr->excl_lock);
|
||||
if (mgr->excl != NULL) {
|
||||
isc_task_detach((isc_task_t **)&mgr->excl);
|
||||
}
|
||||
isc_task_attach(task0, (isc_task_t **)&mgr->excl);
|
||||
isc_task_attach(task, (isc_task_t **)&mgr->excl);
|
||||
UNLOCK(&mgr->excl_lock);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
|
||||
isc__taskmgr_t *mgr = (isc__taskmgr_t *)mgr0;
|
||||
isc_taskmgr_excltask(isc_taskmgr_t *mgr, isc_task_t **taskp) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
REQUIRE(VALID_MANAGER(mgr));
|
||||
@ -1631,9 +1604,8 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_task_beginexclusive(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc__taskmgr_t *manager;
|
||||
isc_task_beginexclusive(isc_task_t *task) {
|
||||
isc_taskmgr_t *manager;
|
||||
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
@ -1669,9 +1641,8 @@ isc_task_beginexclusive(isc_task_t *task0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_endexclusive(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc__taskmgr_t *manager;
|
||||
isc_task_endexclusive(isc_task_t *task) {
|
||||
isc_taskmgr_t *manager;
|
||||
|
||||
REQUIRE(VALID_TASK(task));
|
||||
REQUIRE(task->state == task_state_running);
|
||||
@ -1691,9 +1662,8 @@ isc_task_endexclusive(isc_task_t *task0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_pause(isc_task_t *task0) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task0));
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc_task_pause(isc_task_t *task) {
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
LOCK(&task->lock);
|
||||
task->pause_cnt++;
|
||||
@ -1718,11 +1688,10 @@ isc_task_pause(isc_task_t *task0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_unpause(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc_task_unpause(isc_task_t *task) {
|
||||
bool was_idle = false;
|
||||
|
||||
REQUIRE(ISCAPI_TASK_VALID(task0));
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
LOCK(&task->lock);
|
||||
task->pause_cnt--;
|
||||
@ -1752,10 +1721,9 @@ isc_task_unpause(isc_task_t *task0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_setprivilege(isc_task_t *task0, bool priv) {
|
||||
REQUIRE(ISCAPI_TASK_VALID(task0));
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc__taskmgr_t *manager = task->manager;
|
||||
isc_task_setprivilege(isc_task_t *task, bool priv) {
|
||||
REQUIRE(VALID_TASK(task));
|
||||
isc_taskmgr_t *manager = task->manager;
|
||||
uint_fast32_t oldflags, newflags;
|
||||
|
||||
oldflags = atomic_load_acquire(&task->flags);
|
||||
@ -1783,8 +1751,7 @@ isc_task_setprivilege(isc_task_t *task0, bool priv) {
|
||||
}
|
||||
|
||||
bool
|
||||
isc_task_privilege(isc_task_t *task0) {
|
||||
isc__task_t *task = (isc__task_t *)task0;
|
||||
isc_task_privilege(isc_task_t *task) {
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
return (TASK_PRIVILEGED(task));
|
||||
@ -1792,7 +1759,7 @@ isc_task_privilege(isc_task_t *task0) {
|
||||
|
||||
bool
|
||||
isc_task_exiting(isc_task_t *t) {
|
||||
isc__task_t *task = (isc__task_t *)t;
|
||||
isc_task_t *task = (isc_task_t *)t;
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
return (TASK_SHUTTINGDOWN(task));
|
||||
@ -1806,9 +1773,8 @@ isc_task_exiting(isc_task_t *t) {
|
||||
goto error; \
|
||||
} while (0)
|
||||
int
|
||||
isc_taskmgr_renderxml(isc_taskmgr_t *mgr0, void *writer0) {
|
||||
isc__taskmgr_t *mgr = (isc__taskmgr_t *)mgr0;
|
||||
isc__task_t *task = NULL;
|
||||
isc_taskmgr_renderxml(isc_taskmgr_t *mgr, void *writer0) {
|
||||
isc_task_t *task = NULL;
|
||||
int xmlrc;
|
||||
xmlTextWriterPtr writer = (xmlTextWriterPtr)writer0;
|
||||
|
||||
@ -1916,10 +1882,9 @@ error:
|
||||
} while (0)
|
||||
|
||||
isc_result_t
|
||||
isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, void *tasks0) {
|
||||
isc_taskmgr_renderjson(isc_taskmgr_t *mgr, void *tasks0) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc__taskmgr_t *mgr = (isc__taskmgr_t *)mgr0;
|
||||
isc__task_t *task = NULL;
|
||||
isc_task_t *task = NULL;
|
||||
json_object *obj = NULL, *array = NULL, *taskobj = NULL;
|
||||
json_object *tasks = (json_object *)tasks0;
|
||||
|
||||
|
@ -124,13 +124,13 @@ get_tasks(void **state) {
|
||||
|
||||
/* two tasks in pool; make sure we can access them more than twice */
|
||||
isc_taskpool_gettask(pool, &task1);
|
||||
assert_true(ISCAPI_TASK_VALID(task1));
|
||||
assert_non_null(task1);
|
||||
|
||||
isc_taskpool_gettask(pool, &task2);
|
||||
assert_true(ISCAPI_TASK_VALID(task2));
|
||||
assert_non_null(task2);
|
||||
|
||||
isc_taskpool_gettask(pool, &task3);
|
||||
assert_true(ISCAPI_TASK_VALID(task3));
|
||||
assert_non_null(task3);
|
||||
|
||||
isc_task_destroy(&task1);
|
||||
isc_task_destroy(&task2);
|
||||
@ -159,9 +159,9 @@ set_privilege(void **state) {
|
||||
isc_taskpool_gettask(pool, &task2);
|
||||
isc_taskpool_gettask(pool, &task3);
|
||||
|
||||
assert_true(ISCAPI_TASK_VALID(task1));
|
||||
assert_true(ISCAPI_TASK_VALID(task2));
|
||||
assert_true(ISCAPI_TASK_VALID(task3));
|
||||
assert_non_null(task1);
|
||||
assert_non_null(task2);
|
||||
assert_non_null(task3);
|
||||
|
||||
assert_true(isc_task_privilege(task1));
|
||||
assert_true(isc_task_privilege(task2));
|
||||
|
112
lib/isc/timer.c
112
lib/isc/timer.c
@ -55,13 +55,10 @@
|
||||
#define TIMER_MAGIC ISC_MAGIC('T', 'I', 'M', 'R')
|
||||
#define VALID_TIMER(t) ISC_MAGIC_VALID(t, TIMER_MAGIC)
|
||||
|
||||
typedef struct isc__timer isc__timer_t;
|
||||
typedef struct isc__timermgr isc__timermgr_t;
|
||||
|
||||
struct isc__timer {
|
||||
struct isc_timer {
|
||||
/*! Not locked. */
|
||||
isc_timer_t common;
|
||||
isc__timermgr_t *manager;
|
||||
unsigned int magic;
|
||||
isc_timermgr_t *manager;
|
||||
isc_mutex_t lock;
|
||||
isc_refcount_t references;
|
||||
/*! Locked by timer lock. */
|
||||
@ -75,20 +72,20 @@ struct isc__timer {
|
||||
void *arg;
|
||||
unsigned int index;
|
||||
isc_time_t due;
|
||||
LINK(isc__timer_t) link;
|
||||
LINK(isc_timer_t) link;
|
||||
};
|
||||
|
||||
#define TIMER_MANAGER_MAGIC ISC_MAGIC('T', 'I', 'M', 'M')
|
||||
#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, TIMER_MANAGER_MAGIC)
|
||||
|
||||
struct isc__timermgr {
|
||||
struct isc_timermgr {
|
||||
/* Not locked. */
|
||||
isc_timermgr_t common;
|
||||
unsigned int magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_mutex_t lock;
|
||||
/* Locked by manager lock. */
|
||||
bool done;
|
||||
LIST(isc__timer_t) timers;
|
||||
LIST(isc_timer_t) timers;
|
||||
unsigned int nscheduled;
|
||||
isc_time_t due;
|
||||
isc_condition_t wakeup;
|
||||
@ -100,9 +97,9 @@ void
|
||||
isc_timermgr_poke(isc_timermgr_t *manager0);
|
||||
|
||||
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__timermgr_t *manager;
|
||||
isc_timermgr_t *manager;
|
||||
isc_time_t due;
|
||||
int cmp;
|
||||
|
||||
@ -189,9 +186,9 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
|
||||
}
|
||||
|
||||
static inline void
|
||||
deschedule(isc__timer_t *timer) {
|
||||
deschedule(isc_timer_t *timer) {
|
||||
bool need_wakeup = false;
|
||||
isc__timermgr_t *manager;
|
||||
isc_timermgr_t *manager;
|
||||
|
||||
/*
|
||||
* The caller must ensure locking.
|
||||
@ -214,8 +211,8 @@ deschedule(isc__timer_t *timer) {
|
||||
}
|
||||
|
||||
static void
|
||||
destroy(isc__timer_t *timer) {
|
||||
isc__timermgr_t *manager = timer->manager;
|
||||
destroy(isc_timer_t *timer) {
|
||||
isc_timermgr_t *manager = timer->manager;
|
||||
|
||||
/*
|
||||
* The caller must ensure it is safe to destroy the timer.
|
||||
@ -232,22 +229,20 @@ destroy(isc__timer_t *timer) {
|
||||
|
||||
isc_task_detach(&timer->task);
|
||||
isc_mutex_destroy(&timer->lock);
|
||||
timer->common.impmagic = 0;
|
||||
timer->common.magic = 0;
|
||||
timer->magic = 0;
|
||||
isc_mem_put(manager->mctx, timer, sizeof(*timer));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
|
||||
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(VALID_MANAGER(manager0));
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
REQUIRE(task != NULL);
|
||||
REQUIRE(action != NULL);
|
||||
|
||||
isc__timermgr_t *manager;
|
||||
isc__timer_t *timer;
|
||||
isc_timer_t *timer;
|
||||
isc_result_t result;
|
||||
isc_time_t now;
|
||||
|
||||
@ -258,7 +253,6 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
|
||||
* called with 'arg' as the arg value. The new timer is returned
|
||||
* in 'timerp'.
|
||||
*/
|
||||
manager = (isc__timermgr_t *)manager0;
|
||||
if (expires == NULL) {
|
||||
expires = isc_time_epoch;
|
||||
}
|
||||
@ -320,8 +314,7 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
|
||||
timer->index = 0;
|
||||
isc_mutex_init(&timer->lock);
|
||||
ISC_LINK_INIT(timer, link);
|
||||
timer->common.impmagic = TIMER_MAGIC;
|
||||
timer->common.magic = ISCAPI_TIMER_MAGIC;
|
||||
timer->magic = TIMER_MAGIC;
|
||||
|
||||
LOCK(&manager->lock);
|
||||
|
||||
@ -336,15 +329,14 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
|
||||
result = ISC_R_SUCCESS;
|
||||
}
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
*timerp = (isc_timer_t *)timer;
|
||||
*timerp = timer;
|
||||
APPEND(manager->timers, timer, link);
|
||||
}
|
||||
|
||||
UNLOCK(&manager->lock);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
timer->common.impmagic = 0;
|
||||
timer->common.magic = 0;
|
||||
timer->magic = 0;
|
||||
isc_mutex_destroy(&timer->lock);
|
||||
isc_task_detach(&timer->task);
|
||||
isc_mem_put(manager->mctx, timer, sizeof(*timer));
|
||||
@ -355,12 +347,11 @@ 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 *timer, isc_timertype_t type,
|
||||
const isc_time_t *expires, const isc_interval_t *interval,
|
||||
bool purge) {
|
||||
isc__timer_t *timer;
|
||||
isc_time_t now;
|
||||
isc__timermgr_t *manager;
|
||||
isc_timermgr_t *manager;
|
||||
isc_result_t result;
|
||||
|
||||
/*
|
||||
@ -369,8 +360,7 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
|
||||
* are purged from its task's event queue.
|
||||
*/
|
||||
|
||||
REQUIRE(VALID_TIMER(timer0));
|
||||
timer = (isc__timer_t *)timer0;
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
manager = timer->manager;
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
@ -433,12 +423,10 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
|
||||
}
|
||||
|
||||
isc_timertype_t
|
||||
isc_timer_gettype(isc_timer_t *timer0) {
|
||||
isc__timer_t *timer;
|
||||
isc_timer_gettype(isc_timer_t *timer) {
|
||||
isc_timertype_t t;
|
||||
|
||||
REQUIRE(VALID_TIMER(timer0));
|
||||
timer = (isc__timer_t *)timer0;
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
|
||||
LOCK(&timer->lock);
|
||||
t = timer->type;
|
||||
@ -448,8 +436,7 @@ isc_timer_gettype(isc_timer_t *timer0) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_timer_touch(isc_timer_t *timer0) {
|
||||
isc__timer_t *timer;
|
||||
isc_timer_touch(isc_timer_t *timer) {
|
||||
isc_result_t result;
|
||||
isc_time_t now;
|
||||
|
||||
@ -457,8 +444,7 @@ isc_timer_touch(isc_timer_t *timer0) {
|
||||
* Set the last-touched time of 'timer' to the current time.
|
||||
*/
|
||||
|
||||
REQUIRE(VALID_TIMER(timer0));
|
||||
timer = (isc__timer_t *)timer0;
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
|
||||
LOCK(&timer->lock);
|
||||
|
||||
@ -480,31 +466,28 @@ isc_timer_touch(isc_timer_t *timer0) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
|
||||
isc__timer_t *timer;
|
||||
|
||||
isc_timer_attach(isc_timer_t *timer, isc_timer_t **timerp) {
|
||||
/*
|
||||
* Attach *timerp to timer.
|
||||
*/
|
||||
|
||||
REQUIRE(VALID_TIMER(timer0));
|
||||
timer = (isc__timer_t *)timer0;
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
REQUIRE(timerp != NULL && *timerp == NULL);
|
||||
isc_refcount_increment(&timer->references);
|
||||
|
||||
*timerp = (isc_timer_t *)timer;
|
||||
*timerp = timer;
|
||||
}
|
||||
|
||||
void
|
||||
isc_timer_detach(isc_timer_t **timerp) {
|
||||
isc__timer_t *timer;
|
||||
isc_timer_t *timer;
|
||||
|
||||
/*
|
||||
* Detach *timerp from its timer.
|
||||
*/
|
||||
|
||||
REQUIRE(timerp != NULL);
|
||||
timer = (isc__timer_t *)*timerp;
|
||||
timer = *timerp;
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
|
||||
if (isc_refcount_decrement(&timer->references) == 1) {
|
||||
@ -515,11 +498,11 @@ isc_timer_detach(isc_timer_t **timerp) {
|
||||
}
|
||||
|
||||
static void
|
||||
dispatch(isc__timermgr_t *manager, isc_time_t *now) {
|
||||
dispatch(isc_timermgr_t *manager, isc_time_t *now) {
|
||||
bool done = false, post_event, need_schedule;
|
||||
isc_timerevent_t *event;
|
||||
isc_eventtype_t type = 0;
|
||||
isc__timer_t *timer;
|
||||
isc_timer_t *timer;
|
||||
isc_result_t result;
|
||||
bool idle;
|
||||
|
||||
@ -625,7 +608,7 @@ static isc_threadresult_t
|
||||
WINAPI
|
||||
#endif /* ifdef _WIN32 */
|
||||
run(void *uap) {
|
||||
isc__timermgr_t *manager = uap;
|
||||
isc_timermgr_t *manager = uap;
|
||||
isc_time_t now;
|
||||
isc_result_t result;
|
||||
|
||||
@ -660,7 +643,7 @@ static isc_threadresult_t
|
||||
|
||||
static bool
|
||||
sooner(void *v1, void *v2) {
|
||||
isc__timer_t *t1, *t2;
|
||||
isc_timer_t *t1, *t2;
|
||||
|
||||
t1 = v1;
|
||||
t2 = v2;
|
||||
@ -675,7 +658,7 @@ sooner(void *v1, void *v2) {
|
||||
|
||||
static void
|
||||
set_index(void *what, unsigned int index) {
|
||||
isc__timer_t *timer;
|
||||
isc_timer_t *timer;
|
||||
|
||||
REQUIRE(VALID_TIMER(what));
|
||||
timer = what;
|
||||
@ -685,7 +668,7 @@ set_index(void *what, unsigned int index) {
|
||||
|
||||
isc_result_t
|
||||
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
|
||||
isc__timermgr_t *manager;
|
||||
isc_timermgr_t *manager;
|
||||
isc_result_t result;
|
||||
|
||||
/*
|
||||
@ -696,8 +679,7 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
|
||||
|
||||
manager = isc_mem_get(mctx, sizeof(*manager));
|
||||
|
||||
manager->common.impmagic = TIMER_MANAGER_MAGIC;
|
||||
manager->common.magic = ISCAPI_TIMERMGR_MAGIC;
|
||||
manager->magic = TIMER_MANAGER_MAGIC;
|
||||
manager->mctx = NULL;
|
||||
manager->done = false;
|
||||
INIT_LIST(manager->timers);
|
||||
@ -716,31 +698,28 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
|
||||
isc_thread_create(run, manager, &manager->thread);
|
||||
isc_thread_setname(manager->thread, "isc-timer");
|
||||
|
||||
*managerp = (isc_timermgr_t *)manager;
|
||||
*managerp = manager;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
isc_timermgr_poke(isc_timermgr_t *manager0) {
|
||||
isc__timermgr_t *manager;
|
||||
|
||||
REQUIRE(VALID_MANAGER(manager0));
|
||||
manager = (isc__timermgr_t *)manager0;
|
||||
isc_timermgr_poke(isc_timermgr_t *manager) {
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
SIGNAL(&manager->wakeup);
|
||||
}
|
||||
|
||||
void
|
||||
isc_timermgr_destroy(isc_timermgr_t **managerp) {
|
||||
isc__timermgr_t *manager;
|
||||
isc_timermgr_t *manager;
|
||||
|
||||
/*
|
||||
* Destroy a timer manager.
|
||||
*/
|
||||
|
||||
REQUIRE(managerp != NULL);
|
||||
manager = (isc__timermgr_t *)*managerp;
|
||||
manager = *managerp;
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
LOCK(&manager->lock);
|
||||
@ -764,8 +743,7 @@ isc_timermgr_destroy(isc_timermgr_t **managerp) {
|
||||
(void)isc_condition_destroy(&manager->wakeup);
|
||||
isc_mutex_destroy(&manager->lock);
|
||||
isc_heap_destroy(&manager->heap);
|
||||
manager->common.impmagic = 0;
|
||||
manager->common.magic = 0;
|
||||
manager->magic = 0;
|
||||
isc_mem_putanddetach(&manager->mctx, manager, sizeof(*manager));
|
||||
|
||||
*managerp = NULL;
|
||||
|
@ -319,23 +319,21 @@ typedef isc_event_t intev_t;
|
||||
*/
|
||||
#define NRETRIES 10
|
||||
|
||||
typedef struct isc__socket isc__socket_t;
|
||||
typedef struct isc__socketmgr isc__socketmgr_t;
|
||||
typedef struct isc__socketthread isc__socketthread_t;
|
||||
|
||||
#define NEWCONNSOCK(ev) ((isc__socket_t *)(ev)->newsocket)
|
||||
#define NEWCONNSOCK(ev) ((ev)->newsocket)
|
||||
|
||||
struct isc__socket {
|
||||
struct isc_socket {
|
||||
/* Not locked. */
|
||||
isc_socket_t common;
|
||||
isc__socketmgr_t *manager;
|
||||
unsigned int magic;
|
||||
isc_socketmgr_t *manager;
|
||||
isc_mutex_t lock;
|
||||
isc_sockettype_t type;
|
||||
const isc_statscounter_t *statsindex;
|
||||
isc_refcount_t references;
|
||||
|
||||
/* Locked by socket lock. */
|
||||
ISC_LINK(isc__socket_t) link;
|
||||
ISC_LINK(isc_socket_t) link;
|
||||
int fd;
|
||||
int pf;
|
||||
int threadid;
|
||||
@ -366,9 +364,9 @@ struct isc__socket {
|
||||
#define SOCKET_MANAGER_MAGIC ISC_MAGIC('I', 'O', 'm', 'g')
|
||||
#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, SOCKET_MANAGER_MAGIC)
|
||||
|
||||
struct isc__socketmgr {
|
||||
struct isc_socketmgr {
|
||||
/* Not locked. */
|
||||
isc_socketmgr_t common;
|
||||
unsigned int magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_mutex_t lock;
|
||||
isc_stats_t *stats;
|
||||
@ -376,20 +374,20 @@ struct isc__socketmgr {
|
||||
isc__socketthread_t *threads;
|
||||
unsigned int maxsocks;
|
||||
/* Locked by manager lock. */
|
||||
ISC_LIST(isc__socket_t) socklist;
|
||||
ISC_LIST(isc_socket_t) socklist;
|
||||
int reserved; /* unlocked */
|
||||
isc_condition_t shutdown_ok;
|
||||
size_t maxudp;
|
||||
};
|
||||
|
||||
struct isc__socketthread {
|
||||
isc__socketmgr_t *manager;
|
||||
isc_socketmgr_t *manager;
|
||||
int threadid;
|
||||
isc_thread_t thread;
|
||||
int pipe_fds[2];
|
||||
isc_mutex_t *fdlock;
|
||||
/* Locked by fdlock. */
|
||||
isc__socket_t **fds;
|
||||
isc_socket_t **fds;
|
||||
int *fdstate;
|
||||
#ifdef USE_KQUEUE
|
||||
int kqueue_fd;
|
||||
@ -438,37 +436,37 @@ static isc_result_t
|
||||
socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
|
||||
isc_socket_t **socketp, isc_socket_t *dup_socket);
|
||||
static void
|
||||
send_recvdone_event(isc__socket_t *, isc_socketevent_t **);
|
||||
send_recvdone_event(isc_socket_t *, isc_socketevent_t **);
|
||||
static void
|
||||
send_senddone_event(isc__socket_t *, isc_socketevent_t **);
|
||||
send_senddone_event(isc_socket_t *, isc_socketevent_t **);
|
||||
static void
|
||||
send_connectdone_event(isc__socket_t *, isc_socket_connev_t **);
|
||||
send_connectdone_event(isc_socket_t *, isc_socket_connev_t **);
|
||||
static void
|
||||
free_socket(isc__socket_t **);
|
||||
free_socket(isc_socket_t **);
|
||||
static isc_result_t
|
||||
allocate_socket(isc__socketmgr_t *, isc_sockettype_t, isc__socket_t **);
|
||||
allocate_socket(isc_socketmgr_t *, isc_sockettype_t, isc_socket_t **);
|
||||
static void
|
||||
destroy(isc__socket_t **);
|
||||
destroy(isc_socket_t **);
|
||||
static void
|
||||
internal_accept(isc__socket_t *);
|
||||
internal_accept(isc_socket_t *);
|
||||
static void
|
||||
internal_connect(isc__socket_t *);
|
||||
internal_connect(isc_socket_t *);
|
||||
static void
|
||||
internal_recv(isc__socket_t *);
|
||||
internal_recv(isc_socket_t *);
|
||||
static void
|
||||
internal_send(isc__socket_t *);
|
||||
internal_send(isc_socket_t *);
|
||||
static void
|
||||
process_cmsg(isc__socket_t *, struct msghdr *, isc_socketevent_t *);
|
||||
process_cmsg(isc_socket_t *, struct msghdr *, isc_socketevent_t *);
|
||||
static void
|
||||
build_msghdr_send(isc__socket_t *, char *, isc_socketevent_t *, struct msghdr *,
|
||||
build_msghdr_send(isc_socket_t *, char *, isc_socketevent_t *, struct msghdr *,
|
||||
struct iovec *, size_t *);
|
||||
static void
|
||||
build_msghdr_recv(isc__socket_t *, char *, isc_socketevent_t *, struct msghdr *,
|
||||
build_msghdr_recv(isc_socket_t *, char *, isc_socketevent_t *, struct msghdr *,
|
||||
struct iovec *, size_t *);
|
||||
static bool
|
||||
process_ctlfd(isc__socketthread_t *thread);
|
||||
static void
|
||||
setdscp(isc__socket_t *sock, isc_dscp_t dscp);
|
||||
setdscp(isc_socket_t *sock, isc_dscp_t dscp);
|
||||
|
||||
#define SELECT_POKE_SHUTDOWN (-1)
|
||||
#define SELECT_POKE_NOTHING (-2)
|
||||
@ -559,19 +557,19 @@ static const isc_statscounter_t rawstatsindex[] = {
|
||||
};
|
||||
|
||||
static int
|
||||
gen_threadid(isc__socket_t *sock);
|
||||
gen_threadid(isc_socket_t *sock);
|
||||
|
||||
static int
|
||||
gen_threadid(isc__socket_t *sock) {
|
||||
gen_threadid(isc_socket_t *sock) {
|
||||
return (sock->fd % sock->manager->nthreads);
|
||||
}
|
||||
|
||||
static void
|
||||
manager_log(isc__socketmgr_t *sockmgr, isc_logcategory_t *category,
|
||||
manager_log(isc_socketmgr_t *sockmgr, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level, const char *fmt, ...)
|
||||
ISC_FORMAT_PRINTF(5, 6);
|
||||
static void
|
||||
manager_log(isc__socketmgr_t *sockmgr, isc_logcategory_t *category,
|
||||
manager_log(isc_socketmgr_t *sockmgr, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level, const char *fmt, ...) {
|
||||
char msgbuf[2048];
|
||||
va_list ap;
|
||||
@ -612,11 +610,11 @@ thread_log(isc__socketthread_t *thread, isc_logcategory_t *category,
|
||||
}
|
||||
|
||||
static void
|
||||
socket_log(isc__socket_t *sock, const isc_sockaddr_t *address,
|
||||
socket_log(isc_socket_t *sock, const isc_sockaddr_t *address,
|
||||
isc_logcategory_t *category, isc_logmodule_t *module, int level,
|
||||
const char *fmt, ...) ISC_FORMAT_PRINTF(6, 7);
|
||||
static void
|
||||
socket_log(isc__socket_t *sock, const isc_sockaddr_t *address,
|
||||
socket_log(isc_socket_t *sock, const isc_sockaddr_t *address,
|
||||
isc_logcategory_t *category, isc_logmodule_t *module, int level,
|
||||
const char *fmt, ...) {
|
||||
char msgbuf[2048];
|
||||
@ -923,7 +921,7 @@ wakeup_socket(isc__socketthread_t *thread, int fd, int msg) {
|
||||
* will not get partial writes.
|
||||
*/
|
||||
static void
|
||||
select_poke(isc__socketmgr_t *mgr, int threadid, int fd, int msg) {
|
||||
select_poke(isc_socketmgr_t *mgr, int threadid, int fd, int msg) {
|
||||
int cc;
|
||||
int buf[2];
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
@ -1077,7 +1075,7 @@ cmsg_space(socklen_t len) {
|
||||
* Process control messages received on a socket.
|
||||
*/
|
||||
static void
|
||||
process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
|
||||
process_cmsg(isc_socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
|
||||
#ifdef USE_CMSG
|
||||
struct cmsghdr *cmsgp;
|
||||
struct in6_pktinfo *pktinfop;
|
||||
@ -1195,7 +1193,7 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
|
||||
* this transaction can send.
|
||||
*/
|
||||
static void
|
||||
build_msghdr_send(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
|
||||
build_msghdr_send(isc_socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
|
||||
struct msghdr *msg, struct iovec *iov, size_t *write_countp) {
|
||||
unsigned int iovcount;
|
||||
size_t write_count;
|
||||
@ -1359,7 +1357,7 @@ build_msghdr_send(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
|
||||
* this transaction can receive.
|
||||
*/
|
||||
static void
|
||||
build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
|
||||
build_msghdr_recv(isc_socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
|
||||
struct msghdr *msg, struct iovec *iov, size_t *read_countp) {
|
||||
unsigned int iovcount;
|
||||
size_t read_count;
|
||||
@ -1411,7 +1409,7 @@ build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
|
||||
}
|
||||
|
||||
static void
|
||||
set_dev_address(const isc_sockaddr_t *address, isc__socket_t *sock,
|
||||
set_dev_address(const isc_sockaddr_t *address, isc_socket_t *sock,
|
||||
isc_socketevent_t *dev) {
|
||||
if (sock->type == isc_sockettype_udp) {
|
||||
if (address != NULL) {
|
||||
@ -1476,7 +1474,7 @@ dump_msg(struct msghdr *msg) {
|
||||
#define DOIO_EOF 3 /* EOF, no event sent */
|
||||
|
||||
static int
|
||||
doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
|
||||
doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
|
||||
int cc;
|
||||
struct iovec iov[MAXSCATTERGATHER_RECV];
|
||||
size_t read_count;
|
||||
@ -1651,7 +1649,7 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
|
||||
* No other return values are possible.
|
||||
*/
|
||||
static int
|
||||
doio_send(isc__socket_t *sock, isc_socketevent_t *dev) {
|
||||
doio_send(isc_socket_t *sock, isc_socketevent_t *dev) {
|
||||
int cc;
|
||||
struct iovec iov[MAXSCATTERGATHER_SEND];
|
||||
size_t write_count;
|
||||
@ -1773,7 +1771,7 @@ resend:
|
||||
* references exist.
|
||||
*/
|
||||
static void
|
||||
socketclose(isc__socketthread_t *thread, isc__socket_t *sock, int fd) {
|
||||
socketclose(isc__socketthread_t *thread, isc_socket_t *sock, int fd) {
|
||||
int lockid = FDLOCK_ID(fd);
|
||||
/*
|
||||
* No one has this socket open, so the watcher doesn't have to be
|
||||
@ -1826,10 +1824,10 @@ socketclose(isc__socketthread_t *thread, isc__socket_t *sock, int fd) {
|
||||
}
|
||||
|
||||
static void
|
||||
destroy(isc__socket_t **sockp) {
|
||||
destroy(isc_socket_t **sockp) {
|
||||
int fd = 0;
|
||||
isc__socket_t *sock = *sockp;
|
||||
isc__socketmgr_t *manager = sock->manager;
|
||||
isc_socket_t *sock = *sockp;
|
||||
isc_socketmgr_t *manager = sock->manager;
|
||||
isc__socketthread_t *thread = NULL;
|
||||
|
||||
socket_log(sock, NULL, CREATION, "destroying");
|
||||
@ -1870,14 +1868,13 @@ destroy(isc__socket_t **sockp) {
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
|
||||
isc__socket_t **socketp) {
|
||||
isc__socket_t *sock;
|
||||
allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
|
||||
isc_socket_t **socketp) {
|
||||
isc_socket_t *sock;
|
||||
|
||||
sock = isc_mem_get(manager->mctx, sizeof(*sock));
|
||||
|
||||
sock->common.magic = 0;
|
||||
sock->common.impmagic = 0;
|
||||
sock->magic = 0;
|
||||
isc_refcount_init(&sock->references, 0);
|
||||
|
||||
sock->manager = manager;
|
||||
@ -1913,8 +1910,7 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
|
||||
*/
|
||||
isc_mutex_init(&sock->lock);
|
||||
|
||||
sock->common.magic = ISCAPI_SOCKET_MAGIC;
|
||||
sock->common.impmagic = SOCKET_MAGIC;
|
||||
sock->magic = SOCKET_MAGIC;
|
||||
*socketp = sock;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@ -1928,8 +1924,8 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
|
||||
* also close the socket.
|
||||
*/
|
||||
static void
|
||||
free_socket(isc__socket_t **socketp) {
|
||||
isc__socket_t *sock = *socketp;
|
||||
free_socket(isc_socket_t **socketp) {
|
||||
isc_socket_t *sock = *socketp;
|
||||
*socketp = NULL;
|
||||
|
||||
INSIST(VALID_SOCKET(sock));
|
||||
@ -1943,8 +1939,7 @@ free_socket(isc__socket_t **socketp) {
|
||||
INSIST(!ISC_LINK_LINKED(sock, link));
|
||||
UNLOCK(&sock->lock);
|
||||
|
||||
sock->common.magic = 0;
|
||||
sock->common.impmagic = 0;
|
||||
sock->magic = 0;
|
||||
|
||||
isc_mutex_destroy(&sock->lock);
|
||||
|
||||
@ -2068,7 +2063,7 @@ cleanup:
|
||||
#endif /* ifdef SO_SNDBUF */
|
||||
|
||||
static void
|
||||
use_min_mtu(isc__socket_t *sock) {
|
||||
use_min_mtu(isc_socket_t *sock) {
|
||||
#if !defined(IPV6_USE_MIN_MTU) && !defined(IPV6_MTU)
|
||||
UNUSED(sock);
|
||||
#endif /* if !defined(IPV6_USE_MIN_MTU) && !defined(IPV6_MTU) */
|
||||
@ -2093,7 +2088,7 @@ use_min_mtu(isc__socket_t *sock) {
|
||||
}
|
||||
|
||||
static void
|
||||
set_tcp_maxseg(isc__socket_t *sock, int size) {
|
||||
set_tcp_maxseg(isc_socket_t *sock, int size) {
|
||||
#ifdef TCP_MAXSEG
|
||||
if (sock->type == isc_sockettype_tcp) {
|
||||
(void)setsockopt(sock->fd, IPPROTO_TCP, TCP_MAXSEG,
|
||||
@ -2103,7 +2098,7 @@ set_tcp_maxseg(isc__socket_t *sock, int size) {
|
||||
}
|
||||
|
||||
static void
|
||||
set_ip_dontfrag(isc__socket_t *sock) {
|
||||
set_ip_dontfrag(isc_socket_t *sock) {
|
||||
/*
|
||||
* Set the Don't Fragment flag on IP packets
|
||||
*/
|
||||
@ -2129,8 +2124,8 @@ set_ip_dontfrag(isc__socket_t *sock) {
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
||||
isc__socket_t *dup_socket) {
|
||||
opensocket(isc_socketmgr_t *manager, isc_socket_t *sock,
|
||||
isc_socket_t *dup_socket) {
|
||||
isc_result_t result;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
const char *err = "socket";
|
||||
@ -2433,10 +2428,9 @@ setup_done:
|
||||
* socket is returned in 'socketp'.
|
||||
*/
|
||||
static isc_result_t
|
||||
socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
|
||||
socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
|
||||
isc_socket_t **socketp, isc_socket_t *dup_socket) {
|
||||
isc__socket_t *sock = NULL;
|
||||
isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
|
||||
isc_socket_t *sock = NULL;
|
||||
isc__socketthread_t *thread;
|
||||
isc_result_t result;
|
||||
int lockid;
|
||||
@ -2473,7 +2467,7 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
|
||||
|
||||
sock->pf = pf;
|
||||
|
||||
result = opensocket(manager, sock, (isc__socket_t *)dup_socket);
|
||||
result = opensocket(manager, sock, dup_socket);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
free_socket(&sock);
|
||||
return (result);
|
||||
@ -2485,7 +2479,7 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
|
||||
sock->threadid = gen_threadid(sock);
|
||||
isc_refcount_increment0(&sock->references);
|
||||
thread = &manager->threads[sock->threadid];
|
||||
*socketp = (isc_socket_t *)sock;
|
||||
*socketp = sock;
|
||||
|
||||
/*
|
||||
* Note we don't have to lock the socket like we normally would because
|
||||
@ -2537,20 +2531,17 @@ isc_socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
|
||||
* in 'socketp'.
|
||||
*/
|
||||
isc_result_t
|
||||
isc_socket_dup(isc_socket_t *sock0, isc_socket_t **socketp) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
|
||||
isc_socket_dup(isc_socket_t *sock, isc_socket_t **socketp) {
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
REQUIRE(socketp != NULL && *socketp == NULL);
|
||||
|
||||
return (socket_create((isc_socketmgr_t *)sock->manager, sock->pf,
|
||||
sock->type, socketp, sock0));
|
||||
return (socket_create(sock->manager, sock->pf, sock->type, socketp,
|
||||
sock));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_open(isc_socket_t *sock0) {
|
||||
isc_socket_open(isc_socket_t *sock) {
|
||||
isc_result_t result;
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc__socketthread_t *thread;
|
||||
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
@ -2600,16 +2591,14 @@ isc_socket_open(isc_socket_t *sock0) {
|
||||
* Attach to a socket. Caller must explicitly detach when it is done.
|
||||
*/
|
||||
void
|
||||
isc_socket_attach(isc_socket_t *sock0, isc_socket_t **socketp) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
|
||||
isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp) {
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
REQUIRE(socketp != NULL && *socketp == NULL);
|
||||
|
||||
int old_refs = isc_refcount_increment(&sock->references);
|
||||
REQUIRE(old_refs > 0);
|
||||
|
||||
*socketp = (isc_socket_t *)sock;
|
||||
*socketp = sock;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2618,10 +2607,10 @@ isc_socket_attach(isc_socket_t *sock0, isc_socket_t **socketp) {
|
||||
*/
|
||||
void
|
||||
isc_socket_detach(isc_socket_t **socketp) {
|
||||
isc__socket_t *sock;
|
||||
isc_socket_t *sock;
|
||||
|
||||
REQUIRE(socketp != NULL);
|
||||
sock = (isc__socket_t *)*socketp;
|
||||
sock = *socketp;
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
if (isc_refcount_decrement(&sock->references) == 1) {
|
||||
destroy(&sock);
|
||||
@ -2631,10 +2620,9 @@ isc_socket_detach(isc_socket_t **socketp) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_close(isc_socket_t *sock0) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socket_close(isc_socket_t *sock) {
|
||||
int fd;
|
||||
isc__socketmgr_t *manager;
|
||||
isc_socketmgr_t *manager;
|
||||
isc__socketthread_t *thread;
|
||||
fflush(stdout);
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
@ -2682,7 +2670,7 @@ isc_socket_close(isc_socket_t *sock0) {
|
||||
* Caller must have the socket locked if the event is attached to the socket.
|
||||
*/
|
||||
static void
|
||||
send_recvdone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
|
||||
send_recvdone_event(isc_socket_t *sock, isc_socketevent_t **dev) {
|
||||
isc_task_t *task;
|
||||
|
||||
task = (*dev)->ev_sender;
|
||||
@ -2707,7 +2695,7 @@ send_recvdone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
|
||||
* Caller must have the socket locked if the event is attached to the socket.
|
||||
*/
|
||||
static void
|
||||
send_senddone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
|
||||
send_senddone_event(isc_socket_t *sock, isc_socketevent_t **dev) {
|
||||
isc_task_t *task;
|
||||
|
||||
INSIST(dev != NULL && *dev != NULL);
|
||||
@ -2733,7 +2721,7 @@ send_senddone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
|
||||
* Caller must have the socket locked if the event is attached to the socket.
|
||||
*/
|
||||
static void
|
||||
send_connectdone_event(isc__socket_t *sock, isc_socket_connev_t **dev) {
|
||||
send_connectdone_event(isc_socket_t *sock, isc_socket_connev_t **dev) {
|
||||
isc_task_t *task;
|
||||
|
||||
INSIST(dev != NULL && *dev != NULL);
|
||||
@ -2760,8 +2748,8 @@ send_connectdone_event(isc__socket_t *sock, isc_socket_connev_t **dev) {
|
||||
* so just unlock and return.
|
||||
*/
|
||||
static void
|
||||
internal_accept(isc__socket_t *sock) {
|
||||
isc__socketmgr_t *manager;
|
||||
internal_accept(isc_socket_t *sock) {
|
||||
isc_socketmgr_t *manager;
|
||||
isc__socketthread_t *thread, *nthread;
|
||||
isc_socket_newconnev_t *dev;
|
||||
isc_task_t *task;
|
||||
@ -2998,7 +2986,7 @@ internal_accept(isc__socket_t *sock) {
|
||||
} else {
|
||||
inc_stats(manager->stats, sock->statsindex[STATID_ACCEPTFAIL]);
|
||||
isc_refcount_decrementz(&NEWCONNSOCK(dev)->references);
|
||||
free_socket((isc__socket_t **)&dev->newsocket);
|
||||
free_socket((isc_socket_t **)&dev->newsocket);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3020,7 +3008,7 @@ soft_error:
|
||||
}
|
||||
|
||||
static void
|
||||
internal_recv(isc__socket_t *sock) {
|
||||
internal_recv(isc_socket_t *sock) {
|
||||
isc_socketevent_t *dev;
|
||||
|
||||
INSIST(VALID_SOCKET(sock));
|
||||
@ -3073,7 +3061,7 @@ finish:
|
||||
}
|
||||
|
||||
static void
|
||||
internal_send(isc__socket_t *sock) {
|
||||
internal_send(isc_socket_t *sock) {
|
||||
isc_socketevent_t *dev;
|
||||
|
||||
INSIST(VALID_SOCKET(sock));
|
||||
@ -3117,7 +3105,7 @@ finish:
|
||||
*/
|
||||
static void
|
||||
process_fd(isc__socketthread_t *thread, int fd, bool readable, bool writeable) {
|
||||
isc__socket_t *sock;
|
||||
isc_socket_t *sock;
|
||||
int lockid = FDLOCK_ID(fd);
|
||||
|
||||
/*
|
||||
@ -3364,7 +3352,7 @@ process_ctlfd(isc__socketthread_t *thread) {
|
||||
static isc_threadresult_t
|
||||
netthread(void *uap) {
|
||||
isc__socketthread_t *thread = uap;
|
||||
isc__socketmgr_t *manager = thread->manager;
|
||||
isc_socketmgr_t *manager = thread->manager;
|
||||
(void)manager;
|
||||
bool done;
|
||||
int cc;
|
||||
@ -3522,18 +3510,14 @@ netthread(void *uap) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_socketmgr_setreserved(isc_socketmgr_t *manager0, uint32_t reserved) {
|
||||
isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
|
||||
|
||||
isc_socketmgr_setreserved(isc_socketmgr_t *manager, uint32_t reserved) {
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
manager->reserved = reserved;
|
||||
}
|
||||
|
||||
void
|
||||
isc_socketmgr_maxudp(isc_socketmgr_t *manager0, unsigned int maxudp) {
|
||||
isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
|
||||
|
||||
isc_socketmgr_maxudp(isc_socketmgr_t *manager, unsigned int maxudp) {
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
manager->maxudp = maxudp;
|
||||
@ -3554,9 +3538,9 @@ setup_thread(isc__socketthread_t *thread) {
|
||||
REQUIRE(thread->threadid >= 0 &&
|
||||
thread->threadid < thread->manager->nthreads);
|
||||
|
||||
thread->fds = isc_mem_get(thread->manager->mctx,
|
||||
thread->manager->maxsocks *
|
||||
sizeof(isc__socket_t *));
|
||||
thread->fds =
|
||||
isc_mem_get(thread->manager->mctx,
|
||||
thread->manager->maxsocks * sizeof(isc_socket_t *));
|
||||
|
||||
memset(thread->fds, 0,
|
||||
thread->manager->maxsocks * sizeof(isc_socket_t *));
|
||||
@ -3756,7 +3740,7 @@ cleanup_thread(isc_mem_t *mctx, isc__socketthread_t *thread) {
|
||||
thread->manager->maxsocks * sizeof(uint32_t));
|
||||
#endif /* if defined(USE_EPOLL) */
|
||||
isc_mem_put(thread->manager->mctx, thread->fds,
|
||||
thread->manager->maxsocks * sizeof(isc__socket_t *));
|
||||
thread->manager->maxsocks * sizeof(isc_socket_t *));
|
||||
isc_mem_put(thread->manager->mctx, thread->fdstate,
|
||||
thread->manager->maxsocks * sizeof(int));
|
||||
|
||||
@ -3776,7 +3760,7 @@ isc_result_t
|
||||
isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
|
||||
unsigned int maxsocks, int nthreads) {
|
||||
int i;
|
||||
isc__socketmgr_t *manager;
|
||||
isc_socketmgr_t *manager;
|
||||
|
||||
REQUIRE(managerp != NULL && *managerp == NULL);
|
||||
|
||||
@ -3794,8 +3778,7 @@ isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
|
||||
manager->nthreads = nthreads;
|
||||
manager->stats = NULL;
|
||||
|
||||
manager->common.magic = ISCAPI_SOCKETMGR_MAGIC;
|
||||
manager->common.impmagic = SOCKET_MANAGER_MAGIC;
|
||||
manager->magic = SOCKET_MANAGER_MAGIC;
|
||||
manager->mctx = NULL;
|
||||
ISC_LIST_INIT(manager->socklist);
|
||||
isc_mutex_init(&manager->lock);
|
||||
@ -3819,14 +3802,13 @@ isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
|
||||
isc_thread_setname(manager->threads[i].thread, tname);
|
||||
}
|
||||
|
||||
*managerp = (isc_socketmgr_t *)manager;
|
||||
*managerp = manager;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager0, unsigned int *nsockp) {
|
||||
isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
|
||||
isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager, unsigned int *nsockp) {
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
REQUIRE(nsockp != NULL);
|
||||
|
||||
@ -3836,9 +3818,7 @@ isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager0, unsigned int *nsockp) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_socketmgr_setstats(isc_socketmgr_t *manager0, isc_stats_t *stats) {
|
||||
isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
|
||||
|
||||
isc_socketmgr_setstats(isc_socketmgr_t *manager, isc_stats_t *stats) {
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
REQUIRE(ISC_LIST_EMPTY(manager->socklist));
|
||||
REQUIRE(manager->stats == NULL);
|
||||
@ -3849,14 +3829,14 @@ isc_socketmgr_setstats(isc_socketmgr_t *manager0, isc_stats_t *stats) {
|
||||
|
||||
void
|
||||
isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
|
||||
isc__socketmgr_t *manager;
|
||||
isc_socketmgr_t *manager;
|
||||
|
||||
/*
|
||||
* Destroy a socket manager.
|
||||
*/
|
||||
|
||||
REQUIRE(managerp != NULL);
|
||||
manager = (isc__socketmgr_t *)*managerp;
|
||||
manager = *managerp;
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
LOCK(&manager->lock);
|
||||
@ -3898,15 +3878,14 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
|
||||
isc_stats_detach(&manager->stats);
|
||||
}
|
||||
isc_mutex_destroy(&manager->lock);
|
||||
manager->common.magic = 0;
|
||||
manager->common.impmagic = 0;
|
||||
manager->magic = 0;
|
||||
isc_mem_putanddetach(&manager->mctx, manager, sizeof(*manager));
|
||||
|
||||
*managerp = NULL;
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
|
||||
socket_recv(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
|
||||
unsigned int flags) {
|
||||
int io_state;
|
||||
bool have_lock = false;
|
||||
@ -3983,11 +3962,10 @@ socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_recv(isc_socket_t *sock0, isc_region_t *region, unsigned int minimum,
|
||||
isc_socket_recv(isc_socket_t *sock, isc_region_t *region, unsigned int minimum,
|
||||
isc_task_t *task, isc_taskaction_t action, void *arg) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socketevent_t *dev;
|
||||
isc__socketmgr_t *manager;
|
||||
isc_socketmgr_t *manager;
|
||||
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
REQUIRE(action != NULL);
|
||||
@ -4003,15 +3981,13 @@ isc_socket_recv(isc_socket_t *sock0, isc_region_t *region, unsigned int minimum,
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
return (isc_socket_recv2(sock0, region, minimum, task, dev, 0));
|
||||
return (isc_socket_recv2(sock, region, minimum, task, dev, 0));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_recv2(isc_socket_t *sock0, isc_region_t *region,
|
||||
unsigned int minimum, isc_task_t *task,
|
||||
isc_socketevent_t *event, unsigned int flags) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
|
||||
isc_socket_recv2(isc_socket_t *sock, isc_region_t *region, unsigned int minimum,
|
||||
isc_task_t *task, isc_socketevent_t *event,
|
||||
unsigned int flags) {
|
||||
event->ev_sender = sock;
|
||||
event->result = ISC_R_UNSET;
|
||||
event->region = *region;
|
||||
@ -4036,7 +4012,7 @@ isc_socket_recv2(isc_socket_t *sock0, isc_region_t *region,
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
|
||||
socket_send(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
|
||||
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
|
||||
unsigned int flags) {
|
||||
int io_state;
|
||||
@ -4147,12 +4123,11 @@ isc_socket_send(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_sendto(isc_socket_t *sock0, isc_region_t *region, isc_task_t *task,
|
||||
isc_socket_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__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socketevent_t *dev;
|
||||
isc__socketmgr_t *manager;
|
||||
isc_socketmgr_t *manager;
|
||||
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
REQUIRE(region != NULL);
|
||||
@ -4176,11 +4151,9 @@ isc_socket_sendto(isc_socket_t *sock0, isc_region_t *region, isc_task_t *task,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_sendto2(isc_socket_t *sock0, isc_region_t *region, isc_task_t *task,
|
||||
isc_socket_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__socket_t *sock = (isc__socket_t *)sock0;
|
||||
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
REQUIRE((flags & ~(ISC_SOCKFLAG_IMMEDIATE | ISC_SOCKFLAG_NORETRY)) ==
|
||||
0);
|
||||
@ -4373,9 +4346,8 @@ isc_socket_permunix(const isc_sockaddr_t *sockaddr, uint32_t perm,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_bind(isc_socket_t *sock0, const isc_sockaddr_t *sockaddr,
|
||||
isc_socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr,
|
||||
isc_socket_options_t options) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
int on = 1;
|
||||
|
||||
@ -4463,8 +4435,7 @@ bind_socket:
|
||||
#undef ENABLE_ACCEPTFILTER
|
||||
|
||||
isc_result_t
|
||||
isc_socket_filter(isc_socket_t *sock0, const char *filter) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socket_filter(isc_socket_t *sock, const char *filter) {
|
||||
#if defined(SO_ACCEPTFILTER) && defined(ENABLE_ACCEPTFILTER)
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
struct accept_filter_arg afa;
|
||||
@ -4495,7 +4466,7 @@ isc_socket_filter(isc_socket_t *sock0, const char *filter) {
|
||||
* Try enabling TCP Fast Open for a given socket if the OS supports it.
|
||||
*/
|
||||
static void
|
||||
set_tcp_fastopen(isc__socket_t *sock, unsigned int backlog) {
|
||||
set_tcp_fastopen(isc_socket_t *sock, unsigned int backlog) {
|
||||
#if defined(ENABLE_TCP_FASTOPEN) && defined(TCP_FASTOPEN)
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
@ -4567,8 +4538,7 @@ set_tcp_fastopen(isc__socket_t *sock, unsigned int backlog) {
|
||||
* as well keep things simple rather than having to track them.
|
||||
*/
|
||||
isc_result_t
|
||||
isc_socket_listen(isc_socket_t *sock0, unsigned int backlog) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socket_listen(isc_socket_t *sock, unsigned int backlog) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
@ -4605,13 +4575,12 @@ isc_socket_listen(isc_socket_t *sock0, unsigned int backlog) {
|
||||
* This should try to do aggressive accept() XXXMLG
|
||||
*/
|
||||
isc_result_t
|
||||
isc_socket_accept(isc_socket_t *sock0, isc_task_t *task,
|
||||
isc_taskaction_t action, void *arg) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socket_accept(isc_socket_t *sock, isc_task_t *task, isc_taskaction_t action,
|
||||
void *arg) {
|
||||
isc_socket_newconnev_t *dev;
|
||||
isc__socketmgr_t *manager;
|
||||
isc_socketmgr_t *manager;
|
||||
isc_task_t *ntask = NULL;
|
||||
isc__socket_t *nsock;
|
||||
isc_socket_t *nsock;
|
||||
isc_result_t result;
|
||||
bool do_poke = false;
|
||||
|
||||
@ -4655,7 +4624,7 @@ isc_socket_accept(isc_socket_t *sock0, isc_task_t *task,
|
||||
nsock->statsindex = sock->statsindex;
|
||||
|
||||
dev->ev_sender = ntask;
|
||||
dev->newsocket = (isc_socket_t *)nsock;
|
||||
dev->newsocket = nsock;
|
||||
|
||||
/*
|
||||
* Poke watcher here. We still have the socket locked, so there
|
||||
@ -4673,12 +4642,11 @@ isc_socket_accept(isc_socket_t *sock0, isc_task_t *task,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_connect(isc_socket_t *sock0, const isc_sockaddr_t *addr,
|
||||
isc_socket_connect(isc_socket_t *sock, const isc_sockaddr_t *addr,
|
||||
isc_task_t *task, isc_taskaction_t action, void *arg) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socket_connev_t *dev;
|
||||
isc_task_t *ntask = NULL;
|
||||
isc__socketmgr_t *manager;
|
||||
isc_socketmgr_t *manager;
|
||||
int cc;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
|
||||
@ -4836,7 +4804,7 @@ queue:
|
||||
* Called when a socket with a pending connect() finishes.
|
||||
*/
|
||||
static void
|
||||
internal_connect(isc__socket_t *sock) {
|
||||
internal_connect(isc_socket_t *sock) {
|
||||
isc_socket_connev_t *dev;
|
||||
int cc;
|
||||
isc_result_t result;
|
||||
@ -4937,8 +4905,7 @@ finish:
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_getpeername(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp) {
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
@ -4959,8 +4926,7 @@ isc_socket_getpeername(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_getsockname(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
|
||||
socklen_t len;
|
||||
isc_result_t result;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
@ -4997,9 +4963,7 @@ out:
|
||||
* queued for task "task" of type "how". "how" is a bitmask.
|
||||
*/
|
||||
void
|
||||
isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
|
||||
isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) {
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
|
||||
/*
|
||||
@ -5079,7 +5043,7 @@ isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
|
||||
|
||||
isc_refcount_decrementz(
|
||||
&NEWCONNSOCK(dev)->references);
|
||||
free_socket((isc__socket_t **)&dev->newsocket);
|
||||
free_socket((isc_socket_t **)&dev->newsocket);
|
||||
|
||||
dev->result = ISC_R_CANCELED;
|
||||
dev->ev_sender = sock;
|
||||
@ -5120,17 +5084,14 @@ isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
|
||||
}
|
||||
|
||||
isc_sockettype_t
|
||||
isc_socket_gettype(isc_socket_t *sock0) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
|
||||
isc_socket_gettype(isc_socket_t *sock) {
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
|
||||
return (sock->type);
|
||||
}
|
||||
|
||||
void
|
||||
isc_socket_ipv6only(isc_socket_t *sock0, bool yes) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
isc_socket_ipv6only(isc_socket_t *sock, bool yes) {
|
||||
#if defined(IPV6_V6ONLY)
|
||||
int onoff = yes ? 1 : 0;
|
||||
#else /* if defined(IPV6_V6ONLY) */
|
||||
@ -5158,7 +5119,7 @@ isc_socket_ipv6only(isc_socket_t *sock0, bool yes) {
|
||||
}
|
||||
|
||||
static void
|
||||
setdscp(isc__socket_t *sock, isc_dscp_t dscp) {
|
||||
setdscp(isc_socket_t *sock, isc_dscp_t dscp) {
|
||||
#if defined(IP_TOS) || defined(IPV6_TCLASS)
|
||||
int value = dscp << 2;
|
||||
#endif /* if defined(IP_TOS) || defined(IPV6_TCLASS) */
|
||||
@ -5195,9 +5156,7 @@ setdscp(isc__socket_t *sock, isc_dscp_t dscp) {
|
||||
}
|
||||
|
||||
void
|
||||
isc_socket_dscp(isc_socket_t *sock0, isc_dscp_t dscp) {
|
||||
isc__socket_t *sock = (isc__socket_t *)sock0;
|
||||
|
||||
isc_socket_dscp(isc_socket_t *sock, isc_dscp_t dscp) {
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
REQUIRE(dscp < 0x40);
|
||||
|
||||
@ -5228,9 +5187,7 @@ isc_socket_socketevent(isc_mem_t *mctx, void *sender, isc_eventtype_t eventtype,
|
||||
}
|
||||
|
||||
void
|
||||
isc_socket_setname(isc_socket_t *socket0, const char *name, void *tag) {
|
||||
isc__socket_t *sock = (isc__socket_t *)socket0;
|
||||
|
||||
isc_socket_setname(isc_socket_t *sock, const char *name, void *tag) {
|
||||
/*
|
||||
* Name 'sock'.
|
||||
*/
|
||||
@ -5244,23 +5201,17 @@ isc_socket_setname(isc_socket_t *socket0, const char *name, void *tag) {
|
||||
}
|
||||
|
||||
const char *
|
||||
isc_socket_getname(isc_socket_t *socket0) {
|
||||
isc__socket_t *sock = (isc__socket_t *)socket0;
|
||||
|
||||
isc_socket_getname(isc_socket_t *sock) {
|
||||
return (sock->name);
|
||||
}
|
||||
|
||||
void *
|
||||
isc_socket_gettag(isc_socket_t *socket0) {
|
||||
isc__socket_t *sock = (isc__socket_t *)socket0;
|
||||
|
||||
isc_socket_gettag(isc_socket_t *sock) {
|
||||
return (sock->tag);
|
||||
}
|
||||
|
||||
int
|
||||
isc_socket_getfd(isc_socket_t *socket0) {
|
||||
isc__socket_t *sock = (isc__socket_t *)socket0;
|
||||
|
||||
isc_socket_getfd(isc_socket_t *sock) {
|
||||
return ((short)sock->fd);
|
||||
}
|
||||
|
||||
@ -5336,9 +5287,8 @@ _socktype(isc_sockettype_t type) {
|
||||
goto error; \
|
||||
} while (0)
|
||||
int
|
||||
isc_socketmgr_renderxml(isc_socketmgr_t *mgr0, void *writer0) {
|
||||
isc__socketmgr_t *mgr = (isc__socketmgr_t *)mgr0;
|
||||
isc__socket_t *sock = NULL;
|
||||
isc_socketmgr_renderxml(isc_socketmgr_t *mgr, void *writer0) {
|
||||
isc_socket_t *sock = NULL;
|
||||
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
|
||||
isc_sockaddr_t addr;
|
||||
socklen_t len;
|
||||
@ -5444,10 +5394,9 @@ error:
|
||||
} while (0)
|
||||
|
||||
isc_result_t
|
||||
isc_socketmgr_renderjson(isc_socketmgr_t *mgr0, void *stats0) {
|
||||
isc_socketmgr_renderjson(isc_socketmgr_t *mgr, void *stats0) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc__socketmgr_t *mgr = (isc__socketmgr_t *)mgr0;
|
||||
isc__socket_t *sock = NULL;
|
||||
isc_socket_t *sock = NULL;
|
||||
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
|
||||
isc_sockaddr_t addr;
|
||||
socklen_t len;
|
||||
|
Loading…
x
Reference in New Issue
Block a user