#include <config.h>
#include <isc/app.h>
#include <isc/condition.h>
#include <isc/event.h>
#include <isc/json.h>
#include <isc/magic.h>
#include <isc/mem.h>
#include <isc/msgs.h>
#include <isc/once.h>
#include <isc/platform.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/thread.h>
#include <isc/util.h>
#include <isc/xml.h>
#include "task_p.h"
Go to the source code of this file.
Data Structures | |
struct | isc__task |
struct | isc__taskmethods |
Defines | |
#define | USE_SHARED_MANAGER |
For BIND9 internal applications: when built with threads we use multiple worker threads shared by the whole application. when built without threads we share a single global task manager and use an integrated event loop for socket, timer, and other generic task events. For generic library: we don't use either of them: an application can have multiple task managers whether or not it's threaded, and if the application is threaded each thread is expected to have a separate manager; no "worker threads" are shared by the application threads. | |
#define | XTRACE(m) |
#define | XTTRACE(t, m) |
#define | XTHREADTRACE(m) |
#define | TASK_MAGIC ISC_MAGIC('T', 'A', 'S', 'K') |
#define | VALID_TASK(t) ISC_MAGIC_VALID(t, TASK_MAGIC) |
#define | TASK_F_SHUTTINGDOWN 0x01 |
#define | TASK_F_PRIVILEGED 0x02 |
#define | TASK_SHUTTINGDOWN(t) |
#define | TASK_MANAGER_MAGIC ISC_MAGIC('T', 'S', 'K', 'M') |
#define | VALID_MANAGER(m) ISC_MAGIC_VALID(m, TASK_MANAGER_MAGIC) |
#define | DEFAULT_TASKMGR_QUANTUM 10 |
#define | DEFAULT_DEFAULT_QUANTUM 5 |
#define | FINISHED(m) ((m)->exiting && EMPTY((m)->tasks)) |
#define | PURGE_OK(event) (((event)->ev_attributes & ISC_EVENTATTR_NOPURGE) == 0) |
Typedefs | |
typedef struct isc__task | isc__task_t |
typedef struct isc__taskmgr | isc__taskmgr_t |
Enumerations | |
enum | task_state_t { task_state_idle, task_state_ready, task_state_running, task_state_done } |
Functions | |
typedef | ISC_LIST (isc__task_t) |
isc_result_t | isc__task_create (isc_taskmgr_t *manager0, unsigned int quantum, isc_task_t **taskp) |
The following are intended for internal use (indicated by "isc__" prefix) but are not declared as static, allowing direct access from unit tests etc. | |
void | isc__task_attach (isc_task_t *source0, isc_task_t **targetp) |
void | isc__task_detach (isc_task_t **taskp) |
void | isc__task_send (isc_task_t *task0, isc_event_t **eventp) |
void | isc__task_sendanddetach (isc_task_t **taskp, isc_event_t **eventp) |
unsigned int | isc__task_purgerange (isc_task_t *task0, void *sender, isc_eventtype_t first, isc_eventtype_t last, void *tag) |
unsigned int | isc__task_purge (isc_task_t *task, void *sender, isc_eventtype_t type, void *tag) |
isc_boolean_t | isc_task_purgeevent (isc_task_t *task0, isc_event_t *event) |
unsigned int | isc__task_unsendrange (isc_task_t *task, void *sender, isc_eventtype_t first, isc_eventtype_t last, void *tag, isc_eventlist_t *events) |
unsigned int | isc__task_unsend (isc_task_t *task, void *sender, isc_eventtype_t type, void *tag, isc_eventlist_t *events) |
isc_result_t | isc__task_onshutdown (isc_task_t *task0, isc_taskaction_t action, void *arg) |
void | isc__task_shutdown (isc_task_t *task0) |
void | isc__task_destroy (isc_task_t **taskp) |
void | isc__task_setname (isc_task_t *task0, const char *name, void *tag) |
const char * | isc__task_getname (isc_task_t *task0) |
void * | isc__task_gettag (isc_task_t *task0) |
void | isc__task_getcurrenttime (isc_task_t *task0, isc_stdtime_t *t) |
isc_result_t | isc__taskmgr_create (isc_mem_t *mctx, unsigned int workers, unsigned int default_quantum, isc_taskmgr_t **managerp) |
void | isc__taskmgr_destroy (isc_taskmgr_t **managerp) |
void | isc_taskmgr_setexcltask (isc_taskmgr_t *mgr0, isc_task_t *task0) |
isc_result_t | isc_taskmgr_excltask (isc_taskmgr_t *mgr0, isc_task_t **taskp) |
isc_result_t | isc__task_beginexclusive (isc_task_t *task) |
void | isc__task_endexclusive (isc_task_t *task0) |
void | isc__task_setprivilege (isc_task_t *task0, isc_boolean_t priv) |
isc_boolean_t | isc__task_privilege (isc_task_t *task0) |
void | isc__taskmgr_setmode (isc_taskmgr_t *manager0, isc_taskmgrmode_t mode) |
isc_taskmgrmode_t | isc__taskmgr_mode (isc_taskmgr_t *manager0) |
static isc_boolean_t | empty_readyq (isc__taskmgr_t *manager) |
static isc__task_t * | pop_readyq (isc__taskmgr_t *manager) |
static void | push_readyq (isc__taskmgr_t *manager, isc__task_t *task) |
static void | task_finished (isc__task_t *task) |
static isc_boolean_t | task_shutdown (isc__task_t *task) |
static void | task_ready (isc__task_t *task) |
static isc_boolean_t | task_detach (isc__task_t *task) |
static isc_boolean_t | task_send (isc__task_t *task, isc_event_t **eventp) |
static unsigned int | dequeue_events (isc__task_t *task, void *sender, isc_eventtype_t first, isc_eventtype_t last, void *tag, isc_eventlist_t *events, isc_boolean_t purging) |
static void | dispatch (isc__taskmgr_t *manager) |
static void | manager_free (isc__taskmgr_t *manager) |
isc_boolean_t | isc__taskmgr_ready (isc_taskmgr_t *manager0) |
isc_result_t | isc__taskmgr_dispatch (isc_taskmgr_t *manager0) |
isc_result_t | isc__task_register (void) |
A short cut function that specifies the task management module in the ISC library for isc_task_register(). An application that uses the ISC library usually do not have to care about this function: it would call isc_lib_register(), which internally calls this function. | |
isc_boolean_t | isc_task_exiting (isc_task_t *t) |
Returns ISC_TRUE if the task is in the process of shutting down, ISC_FALSE otherwise. | |
static void | initialize (void) |
isc_result_t | isc_task_register (isc_taskmgrcreatefunc_t createfunc) |
Register a new task management implementation and add it to the list of supported implementations. This function must be called when a different event library is used than the one contained in the ISC library. | |
isc_result_t | isc_taskmgr_createinctx (isc_mem_t *mctx, isc_appctx_t *actx, unsigned int workers, unsigned int default_quantum, isc_taskmgr_t **managerp) |
isc_result_t | isc_taskmgr_create (isc_mem_t *mctx, unsigned int workers, unsigned int default_quantum, isc_taskmgr_t **managerp) |
Create a new task manager. isc_taskmgr_createinctx() also associates the new manager with the specified application context. | |
void | isc_taskmgr_destroy (isc_taskmgr_t **managerp) |
Destroy '*managerp'. | |
void | isc_taskmgr_setmode (isc_taskmgr_t *manager, isc_taskmgrmode_t mode) |
isc_taskmgrmode_t | isc_taskmgr_mode (isc_taskmgr_t *manager) |
Set/get the current operating mode of the task manager. Valid modes are:. | |
isc_result_t | isc_task_create (isc_taskmgr_t *manager, unsigned int quantum, isc_task_t **taskp) |
Create a task. | |
void | isc_task_attach (isc_task_t *source, isc_task_t **targetp) |
Attach *targetp to source. | |
void | isc_task_detach (isc_task_t **taskp) |
Detach *taskp from its task. | |
void | isc_task_send (isc_task_t *task, isc_event_t **eventp) |
Send '*event' to 'task'. | |
void | isc_task_sendanddetach (isc_task_t **taskp, isc_event_t **eventp) |
Send '*event' to '*taskp' and then detach '*taskp' from its task. | |
unsigned int | isc_task_unsend (isc_task_t *task, void *sender, isc_eventtype_t type, void *tag, isc_eventlist_t *events) |
Remove events from a task's event queue. | |
isc_result_t | isc_task_onshutdown (isc_task_t *task, isc_taskaction_t action, void *arg) |
Send a shutdown event with action 'action' and argument 'arg' when 'task' is shutdown. | |
void | isc_task_shutdown (isc_task_t *task) |
Shutdown 'task'. | |
void | isc_task_destroy (isc_task_t **taskp) |
Destroy '*taskp'. | |
void | isc_task_setname (isc_task_t *task, const char *name, void *tag) |
Name 'task'. | |
unsigned int | isc_task_purge (isc_task_t *task, void *sender, isc_eventtype_t type, void *tag) |
Purge events from a task's event queue. | |
isc_result_t | isc_task_beginexclusive (isc_task_t *task) |
Request exclusive access for 'task', which must be the calling task. Waits for any other concurrently executing tasks to finish their current event, and prevents any new events from executing in any of the tasks sharing a task manager with 'task'. | |
void | isc_task_endexclusive (isc_task_t *task) |
Relinquish the exclusive access obtained by isc_task_beginexclusive(), allowing other tasks to execute. | |
void | isc_task_setprivilege (isc_task_t *task, isc_boolean_t priv) |
Set or unset the task's "privileged" flag depending on the value of 'priv'. | |
isc_boolean_t | isc_task_privilege (isc_task_t *task) |
Returns the current value of the task's privilege flag. | |
void | isc_task_getcurrenttime (isc_task_t *task, isc_stdtime_t *t) |
Provide the most recent timestamp on the task. The timestamp is considered as the "current time" in the second-order granularity. | |
unsigned int | isc_task_purgerange (isc_task_t *task, void *sender, isc_eventtype_t first, isc_eventtype_t last, void *tag) |
This is necessary for libisc's internal timer implementation. Other implementation might skip implementing this. | |
Variables | |
static isc__taskmgr_t * | taskmgr = NULL |
static struct isc__taskmethods | taskmethods |
static isc_taskmgrmethods_t | taskmgrmethods |
static isc_mutex_t | createlock |
static isc_once_t | once = ISC_ONCE_INIT |
static isc_taskmgrcreatefunc_t | taskmgr_createfunc = NULL |
Definition in file task.c.
#define USE_SHARED_MANAGER |
For BIND9 internal applications: when built with threads we use multiple worker threads shared by the whole application. when built without threads we share a single global task manager and use an integrated event loop for socket, timer, and other generic task events. For generic library: we don't use either of them: an application can have multiple task managers whether or not it's threaded, and if the application is threaded each thread is expected to have a separate manager; no "worker threads" are shared by the application threads.
#define XTRACE | ( | m | ) |
Definition at line 78 of file task.c.
Referenced by dequeue_events(), deschedule(), dispatch(), isc__task_create(), isc__task_detach(), isc__task_purge(), isc__task_purgerange(), isc__task_send(), isc__task_sendanddetach(), isc__task_unsend(), isc__task_unsendrange(), isc__timermgr_destroy(), schedule(), task_detach(), task_finished(), task_ready(), task_send(), and task_shutdown().
#define XTTRACE | ( | t, | |||
m | ) |
#define XTHREADTRACE | ( | m | ) |
#define TASK_MAGIC ISC_MAGIC('T', 'A', 'S', 'K') |
#define VALID_TASK | ( | t | ) | ISC_MAGIC_VALID(t, TASK_MAGIC) |
Definition at line 99 of file task.c.
Referenced by dequeue_events(), dispatch(), isc__task_attach(), isc__task_detach(), isc__task_getcurrenttime(), isc__task_getname(), isc__task_gettag(), isc__task_onshutdown(), isc__task_send(), isc__task_sendanddetach(), isc__task_setname(), isc__task_shutdown(), isc_task_exiting(), isc_task_purgeevent(), and isc_taskmgr_setexcltask().
#define TASK_F_SHUTTINGDOWN 0x01 |
#define TASK_F_PRIVILEGED 0x02 |
Definition at line 127 of file task.c.
Referenced by dispatch(), isc__task_privilege(), isc__task_setprivilege(), and push_readyq().
#define TASK_SHUTTINGDOWN | ( | t | ) |
Value:
(((t)->flags & TASK_F_SHUTTINGDOWN) \ != 0)
Definition at line 129 of file task.c.
Referenced by dispatch(), isc__task_onshutdown(), isc_task_exiting(), and task_shutdown().
#define TASK_MANAGER_MAGIC ISC_MAGIC('T', 'S', 'K', 'M') |
#define VALID_MANAGER | ( | m | ) | ISC_MAGIC_VALID(m, TASK_MANAGER_MAGIC) |
Definition at line 133 of file task.c.
Referenced by dispatch(), internal_accept(), isc__socket_accept(), isc__socket_fdwatchcreate(), isc__task_create(), isc__taskmgr_destroy(), isc__timer_create(), isc__timer_reset(), isc__timermgr_destroy(), isc_taskmgr_excltask(), isc_taskmgr_setexcltask(), isc_timermgr_poke(), ns_client_dumprecursing(), ns_clientmgr_createclients(), ns_clientmgr_destroy(), socket_create(), and task_ready().
#define DEFAULT_TASKMGR_QUANTUM 10 |
#define DEFAULT_DEFAULT_QUANTUM 5 |
#define FINISHED | ( | m | ) | ((m)->exiting && EMPTY((m)->tasks)) |
typedef struct isc__task isc__task_t |
typedef struct isc__taskmgr isc__taskmgr_t |
enum task_state_t |
typedef ISC_LIST | ( | isc__task_t | ) |
Definition at line 135 of file task.c.
References isc__task::common, isc_thread_t, LIST, isc__task::lock, and mctx.
isc_result_t isc__task_create | ( | isc_taskmgr_t * | manager0, | |
unsigned int | quantum, | |||
isc_task_t ** | taskp | |||
) |
The following are intended for internal use (indicated by "isc__" prefix) but are not declared as static, allowing direct access from unit tests etc.
Definition at line 340 of file task.c.
References APPEND, isc__task::common, DESTROYLOCK, isc__task::events, isc__task::flags, isc_task::impmagic, INIT_LINK, INIT_LIST, ISC_FALSE, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, ISC_TRUE, ISCAPI_TASK_MAGIC, LOCK, isc__task::lock, isc_task::magic, isc__task::manager, isc_task::methods, isc__task::name, isc__task::nevents, isc__task::now, isc__task::on_shutdown, isc__task::quantum, isc__task::references, REQUIRE, isc__task::state, isc__task::tag, TASK_MAGIC, task_state_idle, taskmethods, UNLOCK, VALID_MANAGER, and XTRACE.
Referenced by isc_task_create().
void isc__task_attach | ( | isc_task_t * | source0, | |
isc_task_t ** | targetp | |||
) |
Definition at line 400 of file task.c.
References isc__task::lock, LOCK, isc__task::references, REQUIRE, UNLOCK, VALID_TASK, and XTTRACE.
Referenced by isc_task_attach(), isc_taskmgr_excltask(), and isc_taskmgr_setexcltask().
void isc__task_detach | ( | isc_task_t ** | taskp | ) |
Definition at line 514 of file task.c.
References isc__task::lock, LOCK, REQUIRE, task_detach(), task_ready(), UNLOCK, VALID_TASK, and XTRACE.
Referenced by isc__taskmgr_destroy(), isc_task_detach(), and isc_taskmgr_setexcltask().
void isc__task_send | ( | isc_task_t * | task0, | |
isc_event_t ** | eventp | |||
) |
Definition at line 570 of file task.c.
References isc__task::lock, LOCK, REQUIRE, task_ready(), task_send(), UNLOCK, VALID_TASK, and XTRACE.
Referenced by isc_task_send().
void isc__task_sendanddetach | ( | isc_task_t ** | taskp, | |
isc_event_t ** | eventp | |||
) |
Definition at line 612 of file task.c.
References INSIST, isc__task::lock, LOCK, REQUIRE, task_detach(), task_ready(), task_send(), UNLOCK, VALID_TASK, and XTRACE.
Referenced by isc_task_sendanddetach().
unsigned int isc__task_purgerange | ( | isc_task_t * | task0, | |
void * | sender, | |||
isc_eventtype_t | first, | |||
isc_eventtype_t | last, | |||
void * | tag | |||
) |
Definition at line 689 of file task.c.
References dequeue_events(), isc__task::events, HEAD, isc_event_free(), ISC_LIST_INIT, ISC_TRUE, NEXT, and XTRACE.
Referenced by isc__task_purge(), and isc_task_purgerange().
unsigned int isc__task_purge | ( | isc_task_t * | task, | |
void * | sender, | |||
isc_eventtype_t | type, | |||
void * | tag | |||
) |
Definition at line 721 of file task.c.
References isc__task_purgerange(), and XTRACE.
Referenced by isc_task_purge().
isc_boolean_t isc_task_purgeevent | ( | isc_task_t * | task0, | |
isc_event_t * | event | |||
) |
unsigned int isc__task_unsendrange | ( | isc_task_t * | task, | |
void * | sender, | |||
isc_eventtype_t | first, | |||
isc_eventtype_t | last, | |||
void * | tag, | |||
isc_eventlist_t * | events | |||
) |
unsigned int isc__task_unsend | ( | isc_task_t * | task, | |
void * | sender, | |||
isc_eventtype_t | type, | |||
void * | tag, | |||
isc_eventlist_t * | events | |||
) |
Definition at line 793 of file task.c.
References dequeue_events(), ISC_FALSE, and XTRACE.
Referenced by isc_task_unsend().
isc_result_t isc__task_onshutdown | ( | isc_task_t * | task0, | |
isc_taskaction_t | action, | |||
void * | arg | |||
) |
Definition at line 807 of file task.c.
References ENQUEUE, isc_event_allocate(), ISC_FALSE, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, ISC_TASKEVENT_SHUTDOWN, ISC_TRUE, isc__task::lock, LOCK, isc__task::manager, isc__task::on_shutdown, REQUIRE, TASK_SHUTTINGDOWN, UNLOCK, and VALID_TASK.
Referenced by isc_task_onshutdown().
void isc__task_shutdown | ( | isc_task_t * | task0 | ) |
Definition at line 847 of file task.c.
References isc__task::lock, LOCK, REQUIRE, task_ready(), task_shutdown(), UNLOCK, and VALID_TASK.
Referenced by isc_task_shutdown().
void isc__task_destroy | ( | isc_task_t ** | taskp | ) |
Definition at line 866 of file task.c.
References isc_task_detach(), isc_task_shutdown(), and REQUIRE.
Referenced by isc_task_destroy().
void isc__task_setname | ( | isc_task_t * | task0, | |
const char * | name, | |||
void * | tag | |||
) |
Definition at line 879 of file task.c.
References isc__task::lock, LOCK, isc__task::name, REQUIRE, isc__task::tag, UNLOCK, and VALID_TASK.
Referenced by isc_task_setname().
const char * isc__task_getname | ( | isc_task_t * | task0 | ) |
void * isc__task_gettag | ( | isc_task_t * | task0 | ) |
void isc__task_getcurrenttime | ( | isc_task_t * | task0, | |
isc_stdtime_t * | t | |||
) |
Definition at line 914 of file task.c.
References isc__task::lock, LOCK, isc__task::now, REQUIRE, UNLOCK, and VALID_TASK.
Referenced by isc_task_getcurrenttime().
isc_result_t isc__taskmgr_create | ( | isc_mem_t * | mctx, | |
unsigned int | workers, | |||
unsigned int | default_quantum, | |||
isc_taskmgr_t ** | managerp | |||
) |
Definition at line 1338 of file task.c.
References DEFAULT_DEFAULT_QUANTUM, DESTROYLOCK, INIT_LIST, isc_condition_destroy, isc_condition_init, ISC_FALSE, isc_mem_allocate, isc_mem_attach(), isc_mem_free, isc_mem_get, isc_mem_put, ISC_MSG_FAILED, isc_msgcat_get(), ISC_MSGSET_GENERAL, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_NOTHREADS, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_taskmgrmode_normal, isc_thread_create(), isc_thread_setconcurrency(), isc_thread_t, ISCAPI_TASKMGR_MAGIC, LOCK, manager_free(), REQUIRE, run, TASK_MANAGER_MAGIC, taskmgr, taskmgrmethods, UNEXPECTED_ERROR, UNLOCK, and UNUSED.
Referenced by isc__task_register(), and isc_taskmgr_create().
void isc__taskmgr_destroy | ( | isc_taskmgr_t ** | managerp | ) |
Definition at line 1478 of file task.c.
References BROADCAST, HEAD, INSIST, isc__task_detach(), isc__taskmgr_dispatch(), isc__taskmgr_ready(), ISC_LIST_EMPTY, isc_mem_printallactive(), isc_taskmgrmode_normal, isc_thread_join, ISC_TRUE, isc__task::lock, LOCK, manager_free(), NEXT, push_readyq(), REQUIRE, task_shutdown(), taskmgr, UNLOCK, UNUSED, VALID_MANAGER, and XTHREADTRACE.
Referenced by isc_taskmgr_destroy().
void isc_taskmgr_setexcltask | ( | isc_taskmgr_t * | mgr0, | |
isc_task_t * | task0 | |||
) |
isc_result_t isc_taskmgr_excltask | ( | isc_taskmgr_t * | mgr0, | |
isc_task_t ** | taskp | |||
) |
isc_result_t isc__task_beginexclusive | ( | isc_task_t * | task | ) |
Definition at line 1700 of file task.c.
References ISC_R_LOCKBUSY, ISC_R_SUCCESS, ISC_TRUE, LOCK, isc__task::manager, REQUIRE, isc__task::state, task_state_running, UNLOCK, UNUSED, and WAIT.
Referenced by isc_task_beginexclusive().
void isc__task_endexclusive | ( | isc_task_t * | task0 | ) |
Definition at line 1725 of file task.c.
References BROADCAST, ISC_FALSE, LOCK, isc__task::manager, REQUIRE, isc__task::state, task_state_running, UNLOCK, and UNUSED.
Referenced by isc_task_endexclusive().
void isc__task_setprivilege | ( | isc_task_t * | task0, | |
isc_boolean_t | priv | |||
) |
Definition at line 1742 of file task.c.
References DEQUEUE, ENQUEUE, isc__task::flags, ISC_LINK_LINKED, ISC_TF, isc__task::lock, LOCK, isc__task::manager, TASK_F_PRIVILEGED, and UNLOCK.
Referenced by isc_task_setprivilege().
isc_boolean_t isc__task_privilege | ( | isc_task_t * | task0 | ) |
Definition at line 1769 of file task.c.
References isc__task::flags, ISC_TF, isc__task::lock, LOCK, TASK_F_PRIVILEGED, and UNLOCK.
Referenced by isc_task_privilege(), and task_ready().
void isc__taskmgr_setmode | ( | isc_taskmgr_t * | manager0, | |
isc_taskmgrmode_t | mode | |||
) |
isc_taskmgrmode_t isc__taskmgr_mode | ( | isc_taskmgr_t * | manager0 | ) |
static isc_boolean_t empty_readyq | ( | isc__taskmgr_t * | manager | ) | [inline, static] |
Definition at line 937 of file task.c.
References EMPTY, isc_taskmgrmode_normal, and ISC_TF.
Referenced by dispatch(), and isc__taskmgr_ready().
static isc__task_t * pop_readyq | ( | isc__taskmgr_t * | manager | ) | [inline, static] |
Definition at line 957 of file task.c.
References DEQUEUE, HEAD, ISC_LINK_LINKED, and isc_taskmgrmode_normal.
Referenced by dispatch().
static void push_readyq | ( | isc__taskmgr_t * | manager, | |
isc__task_t * | task | |||
) | [inline, static] |
Definition at line 982 of file task.c.
References ENQUEUE, isc__task::flags, and TASK_F_PRIVILEGED.
Referenced by dispatch(), isc__taskmgr_destroy(), and task_ready().
static void task_finished | ( | isc__task_t * | task | ) | [static] |
Definition at line 307 of file task.c.
References BROADCAST, isc__task::common, DESTROYLOCK, EMPTY, isc__task::events, FINISHED, isc_task::impmagic, isc_mem_put, isc__task::lock, LOCK, isc_task::magic, isc__task::manager, isc__task::nevents, isc__task::on_shutdown, isc__task::references, REQUIRE, isc__task::state, task_state_done, UNLINK, UNLOCK, and XTRACE.
Referenced by dispatch().
static isc_boolean_t task_shutdown | ( | isc__task_t * | task | ) | [inline, static] |
Definition at line 420 of file task.c.
References DEQUEUE, EMPTY, ENQUEUE, isc__task::events, isc__task::flags, INSIST, ISC_FALSE, ISC_MSG_SHUTTINGDOWN, isc_msgcat_get(), ISC_MSGSET_GENERAL, ISC_TRUE, isc__task::nevents, isc__task::on_shutdown, PREV, isc__task::state, TAIL, TASK_F_SHUTTINGDOWN, TASK_SHUTTINGDOWN, task_state_idle, task_state_ready, task_state_running, and XTRACE.
Referenced by dispatch(), isc__task_shutdown(), and isc__taskmgr_destroy().
static void task_ready | ( | isc__task_t * | task | ) | [inline, static] |
Definition at line 464 of file task.c.
References isc__task_privilege(), isc_taskmgrmode_normal, LOCK, isc__task::manager, push_readyq(), REQUIRE, SIGNAL, task_state_ready, UNLOCK, VALID_MANAGER, and XTRACE.
Referenced by isc__task_detach(), isc__task_send(), isc__task_sendanddetach(), and isc__task_shutdown().
static isc_boolean_t task_detach | ( | isc__task_t * | task | ) | [inline, static] |
Definition at line 485 of file task.c.
References EMPTY, isc__task::events, INSIST, ISC_FALSE, ISC_TRUE, isc__task::references, REQUIRE, isc__task::state, task_state_idle, task_state_ready, and XTRACE.
Referenced by isc__task_detach(), and isc__task_sendanddetach().
static isc_boolean_t task_send | ( | isc__task_t * | task, | |
isc_event_t ** | eventp | |||
) | [inline, static] |
Definition at line 539 of file task.c.
References EMPTY, ENQUEUE, isc__task::events, INSIST, ISC_FALSE, ISC_TRUE, isc__task::nevents, REQUIRE, isc__task::state, task_state_done, task_state_idle, task_state_ready, task_state_running, and XTRACE.
Referenced by dns_master_dumpinc3(), dns_master_dumptostreaminc(), dns_master_loadbufferinc(), dns_master_loadfileinc5(), dns_master_loadlexerinc(), dns_master_loadstreaminc(), isc__task_send(), and isc__task_sendanddetach().
static unsigned int dequeue_events | ( | isc__task_t * | task, | |
void * | sender, | |||
isc_eventtype_t | first, | |||
isc_eventtype_t | last, | |||
void * | tag, | |||
isc_eventlist_t * | events, | |||
isc_boolean_t | purging | |||
) | [static] |
Definition at line 648 of file task.c.
References DEQUEUE, ENQUEUE, isc__task::events, HEAD, isc__task::lock, LOCK, isc__task::nevents, NEXT, PURGE_OK, REQUIRE, UNLOCK, VALID_TASK, and XTRACE.
Referenced by isc__task_purgerange(), isc__task_unsend(), and isc__task_unsendrange().
static void dispatch | ( | isc__taskmgr_t * | manager | ) | [static] |
Definition at line 991 of file task.c.
References BROADCAST, DEFAULT_TASKMGR_QUANTUM, DEQUEUE, EMPTY, empty_readyq(), ENQUEUE, isc__task::events, finished, FINISHED, isc__task::flags, HEAD, INSIST, ISC_FALSE, ISC_LIST_APPENDLIST, ISC_LIST_INIT, ISC_MSG_AWAKE, ISC_MSG_DONE, ISC_MSG_EMPTY, ISC_MSG_EXECUTE, ISC_MSG_QUANTUM, ISC_MSG_RUNNING, ISC_MSG_WAIT, ISC_MSG_WORKING, isc_msgcat_get(), ISC_MSGSET_GENERAL, ISC_MSGSET_TASK, isc_stdtime_get(), isc_taskmgrmode_normal, ISC_TRUE, isc__task::lock, LOCK, isc__task::nevents, isc__task::now, pop_readyq(), push_readyq(), isc__task::quantum, isc__task::references, REQUIRE, SIGNAL, isc__task::state, TASK_F_PRIVILEGED, task_finished(), task_shutdown(), TASK_SHUTTINGDOWN, task_state_done, task_state_idle, task_state_ready, task_state_running, UNLOCK, VALID_MANAGER, VALID_TASK, WAIT, XTHREADTRACE, and XTRACE.
Referenced by isc__taskmgr_dispatch(), and isc__timermgr_dispatch().
static void manager_free | ( | isc__taskmgr_t * | manager | ) | [static] |
Definition at line 1315 of file task.c.
References DESTROYLOCK, isc_condition_destroy, isc_mem_detach(), isc_mem_free, isc_mem_put, mctx, and taskmgr.
Referenced by isc__taskmgr_create(), and isc__taskmgr_destroy().
isc_boolean_t isc__taskmgr_ready | ( | isc_taskmgr_t * | manager0 | ) |
Definition at line 1609 of file task.c.
References empty_readyq(), ISC_FALSE, LOCK, taskmgr, and UNLOCK.
Referenced by ATF_TC_BODY(), evloop(), isc__taskmgr_destroy(), waitbody(), and waitfor().
isc_result_t isc__taskmgr_dispatch | ( | isc_taskmgr_t * | manager0 | ) |
Definition at line 1628 of file task.c.
References dispatch(), ISC_R_NOTFOUND, ISC_R_SUCCESS, and taskmgr.
Referenced by ATF_TC_BODY(), evloop(), isc__app_ctxrun(), isc__taskmgr_destroy(), waitbody(), and waitfor().
isc_result_t isc__task_register | ( | void | ) |
A short cut function that specifies the task management module in the ISC library for isc_task_register(). An application that uses the ISC library usually do not have to care about this function: it would call isc_lib_register(), which internally calls this function.
Definition at line 1780 of file task.c.
References isc__taskmgr_create(), and isc_task_register().
Referenced by do_register().
isc_boolean_t isc_task_exiting | ( | isc_task_t * | t | ) |
Returns ISC_TRUE if the task is in the process of shutting down, ISC_FALSE otherwise.
Requires:
Definition at line 1785 of file task.c.
References REQUIRE, TASK_SHUTTINGDOWN, and VALID_TASK.
Referenced by isc__socket_accept().
static void initialize | ( | void | ) | [static] |
Definition at line 2014 of file task.c.
References isc_mutex_init, ISC_R_SUCCESS, and RUNTIME_CHECK.
isc_result_t isc_task_register | ( | isc_taskmgrcreatefunc_t | createfunc | ) |
Register a new task management implementation and add it to the list of supported implementations. This function must be called when a different event library is used than the one contained in the ISC library.
Definition at line 2019 of file task.c.
References initialize(), isc_once_do, ISC_R_EXISTS, ISC_R_SUCCESS, LOCK, RUNTIME_CHECK, and UNLOCK.
Referenced by isc__task_register().
isc_result_t isc_taskmgr_createinctx | ( | isc_mem_t * | mctx, | |
isc_appctx_t * | actx, | |||
unsigned int | workers, | |||
unsigned int | default_quantum, | |||
isc_taskmgr_t ** | managerp | |||
) |
Definition at line 2035 of file task.c.
References isc_appctx_settaskmgr(), ISC_R_SUCCESS, LOCK, REQUIRE, and UNLOCK.
Referenced by dns_client_create().
isc_result_t isc_taskmgr_create | ( | isc_mem_t * | mctx, | |
unsigned int | workers, | |||
unsigned int | default_quantum, | |||
isc_taskmgr_t ** | managerp | |||
) |
Create a new task manager. isc_taskmgr_createinctx() also associates the new manager with the specified application context.
Notes:
Definition at line 2056 of file task.c.
References isc__taskmgr_create(), isc_bind9, LOCK, REQUIRE, and UNLOCK.
Referenced by create_managers(), main(), setup_libs(), and setup_system().
void isc_taskmgr_destroy | ( | isc_taskmgr_t ** | managerp | ) |
Destroy '*managerp'.
Notes:
Definition at line 2076 of file task.c.
References ENSURE, isc__taskmgr_destroy(), isc_bind9, ISCAPI_TASKMGR_VALID, and REQUIRE.
Referenced by cleanup(), cleanup_managers(), destroy_libs(), destroy_managers(), destroyclient(), dns_client_create(), isc_test_end(), and main().
void isc_taskmgr_setmode | ( | isc_taskmgr_t * | manager, | |
isc_taskmgrmode_t | mode | |||
) |
Definition at line 2088 of file task.c.
References isc__taskmgr_setmode(), isc_bind9, ISCAPI_TASKMGR_VALID, isc_taskmgr::methods, REQUIRE, and isc_taskmgrmethods::setmode.
Referenced by ATF_TC_BODY(), load_zones(), and set_and_drop().
isc_taskmgrmode_t isc_taskmgr_mode | ( | isc_taskmgr_t * | manager | ) |
Set/get the current operating mode of the task manager. Valid modes are:.
Requires:
Definition at line 2098 of file task.c.
References isc__taskmgr_mode(), isc_bind9, ISCAPI_TASKMGR_VALID, isc_taskmgr::methods, isc_taskmgrmethods::mode, and REQUIRE.
Referenced by ATF_TC_BODY(), and set_and_drop().
isc_result_t isc_task_create | ( | isc_taskmgr_t * | manager, | |
unsigned int | quantum, | |||
isc_task_t ** | taskp | |||
) |
Create a task.
Notes:
Definition at line 2108 of file task.c.
References isc__task_create(), isc_bind9, ISCAPI_TASKMGR_VALID, isc_taskmgr::methods, REQUIRE, and isc_taskmgrmethods::taskcreate.
Referenced by add_listener(), ATF_TC_BODY(), cache_cleaner_init(), client_create(), create_managers(), dispatch_createudp(), dns_acache_create(), dns_adb_create(), dns_cache_create3(), dns_client_createx2(), dns_dispatch_createtcp2(), dns_ntatable_create(), dns_resolver_create(), dns_view_createresolver(), dns_zonemgr_create(), isc_taskpool_create(), isc_taskpool_expand(), main(), ns_lwdclientmgr_create(), ns_server_create(), poolinit(), setup_libs(), and setup_system().
void isc_task_attach | ( | isc_task_t * | source, | |
isc_task_t ** | targetp | |||
) |
Attach *targetp to source.
Requires:
Definition at line 2121 of file task.c.
References isc_taskmethods::attach, ENSURE, isc__task_attach(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, and REQUIRE.
Referenced by ATF_TC_BODY(), dns_adb_createfind2(), dns_adb_whenshutdown(), dns_byaddr_create(), dns_client_startrequest(), dns_client_startresolve(), dns_client_startupdate(), dns_dispatch_addresponse3(), dns_lookup_create(), dns_master_dumpinc3(), dns_master_dumptostreaminc(), dns_request_createraw4(), dns_request_createvia4(), dns_requestmgr_whenshutdown(), dns_resolver_whenshutdown(), dns_validator_create(), dns_zone_gettask(), dns_zone_link(), dns_zone_settask(), fctx_join(), get_dispsocket(), isc__app_ctxonrun(), isc__socket_accept(), isc__timer_create(), isc_httpdmgr_create(), isc_ondestroy_register(), isc_taskpool_gettask(), loadctx_create(), ns_interfacemgr_create(), ns_server_dumpdb(), settask(), xfrin_create(), and zonemgr_getio().
void isc_task_detach | ( | isc_task_t ** | taskp | ) |
Detach *taskp from its task.
Requires:
Definition at line 2134 of file task.c.
References ENSURE, isc__task_detach(), isc_bind9, ISCAPI_TASK_VALID, and REQUIRE.
Referenced by add_listener(), assignwork(), ATF_TC_BODY(), cache_cleaner_init(), cache_free(), client_create(), destroy(), destroy_disp(), destroy_dispsocket(), destroy_libs(), destroyclient(), dispatch_createudp(), dns_acache_create(), dns_adb_create(), dns_byaddr_create(), dns_cache_create3(), dns_client_createx2(), dns_client_startrequest(), dns_client_startresolve(), dns_client_startupdate(), dns_dispatch_addresponse3(), dns_dispatch_createtcp2(), dns_dispatch_removeresponse(), dns_lookup_create(), dns_ntatable_create(), dns_ntatable_detach(), dns_request_createraw4(), dns_request_createvia4(), dns_resolver_create(), dns_validator_create(), dns_view_createresolver(), dns_zone_settask(), dns_zonemgr_create(), dns_zonemgr_managezone(), doshutdown(), dumpcontext_destroy(), dumpctx_destroy(), exit_check(), fctx_join(), forward_action(), free_rbtdb(), httpdmgr_destroy(), isc__socket_accept(), isc__task_destroy(), isc__timer_create(), isc_httpdmgr_create(), isc_taskpool_destroy(), isc_test_end(), loadctx_destroy(), lwdclientmgr_destroy(), main(), maybe_free(), ns_interfacemgr_create(), ns_interfacemgr_destroy(), ns_interfacemgr_shutdown(), ns_lwdclientmgr_create(), settask(), shutdown_server(), update_action(), xfrin_create(), zone_free(), and zonemgr_putio().
void isc_task_send | ( | isc_task_t * | task, | |
isc_event_t ** | eventp | |||
) |
Send '*event' to 'task'.
Requires:
Definition at line 2146 of file task.c.
References ENSURE, isc__task_send(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, REQUIRE, and isc_taskmethods::send.
Referenced by acache_incremental_cleaning_action(), assignwork(), ATF_TC_BODY(), begin_cleaning(), check_exit(), cleanup_dead_nodes_callback(), closeversion(), decrement_reference(), dighost_shutdown(), dispatch(), dlv_validator_start(), dns_acache_shutdown(), dns_adb_shutdown(), dns_adb_whenshutdown(), dns_dispatch_addresponse3(), dns_dispatch_detach(), dns_dispatch_importrecv(), dns_dispatch_removeresponse(), dns_request_cancel(), dns_requestmgr_whenshutdown(), dns_resolver_createfetch3(), dns_resolver_whenshutdown(), dns_validator_create(), dns_validator_send(), dns_zone_asyncload(), dns_zone_detach(), do_cancel(), done_update(), dump_quantum(), fctx_shutdown(), force_timeout(), forward_action(), forward_callback(), free_rbtdb(), get_client(), get_worker(), incremental_cleaning_action(), isc_ratelimiter_enqueue(), isc_ratelimiter_shutdown(), load_quantum(), new_adbentry(), new_adbname(), ns_server_reloadwanted(), ratelimiter_tick(), receive_secure_serial(), recv_length(), recv_message(), send_forward_event(), send_recvdone_event(), send_senddone_event(), send_update_event(), sign(), task_send(), tcp_recv(), udp_recv(), update_action(), water(), zmgr_start_xfrin_ifquota(), zone_send_securedb(), zone_send_secureserial(), zonemgr_cancelio(), zonemgr_getio(), and zonemgr_putio().
void isc_task_sendanddetach | ( | isc_task_t ** | taskp, | |
isc_event_t ** | eventp | |||
) |
Send '*event' to '*taskp' and then detach '*taskp' from its task.
Requires:
Definition at line 2159 of file task.c.
References ENSURE, isc__task_sendanddetach(), isc_bind9, ISCAPI_TASK_VALID, and REQUIRE.
Referenced by clean_finds_at_name(), client_resfind(), dec_adb_irefcnt(), dns_adb_cancelfind(), dns_resolver_cancelfetch(), fctx_sendevents(), internal_accept(), isc__app_ctxrun(), isc__socket_cancel(), isc_ondestroy_notify(), lookup_done(), lookup_find(), req_sendevent(), request_done(), send_connectdone_event(), send_recvdone_event(), send_senddone_event(), send_shutdown_events(), update_sendevent(), and validator_done().
unsigned int isc_task_unsend | ( | isc_task_t * | task, | |
void * | sender, | |||
isc_eventtype_t | type, | |||
void * | tag, | |||
isc_eventlist_t * | events | |||
) |
Remove events from a task's event queue.
Notes:
isc_task_unsendrange(task, sender, type, type, tag, events); *
Requires:
Definition at line 2174 of file task.c.
References isc__task_unsend(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, REQUIRE, and isc_taskmethods::unsend.
Referenced by dns_dispatch_removeresponse().
isc_result_t isc_task_onshutdown | ( | isc_task_t * | task, | |
isc_taskaction_t | action, | |||
void * | arg | |||
) |
Send a shutdown event with action 'action' and argument 'arg' when 'task' is shutdown.
Notes:
Definition at line 2186 of file task.c.
References isc__task_onshutdown(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, isc_taskmethods::onshutdown, and REQUIRE.
Referenced by acache_cleaner_init(), cache_cleaner_init(), client_create(), ns_lwdclientmgr_create(), ns_server_create(), and setup_system().
void isc_task_shutdown | ( | isc_task_t * | task | ) |
Shutdown 'task'.
Notes:
Definition at line 2197 of file task.c.
References isc__task_shutdown(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, REQUIRE, and isc_taskmethods::shutdown.
Referenced by client_request(), destroy(), dispatch_createudp(), dns_acache_detach(), dns_cache_detach(), dns_resolver_create(), exit_check(), isc__task_destroy(), listener_shutdown(), ns_clientmgr_destroy(), rndc_recvdone(), and rndc_senddone().
void isc_task_destroy | ( | isc_task_t ** | taskp | ) |
Destroy '*taskp'.
Notes:
isc_task_shutdown(*taskp); isc_task_detach(taskp); *
Requires:
'*taskp' is a valid task.
Ensures:
Definition at line 2207 of file task.c.
References isc__task_destroy(), and isc_bind9.
Referenced by ATF_TC_BODY(), cleanup_managers(), dns_zonemgr_shutdown(), and poolfree().
void isc_task_setname | ( | isc_task_t * | task, | |
const char * | name, | |||
void * | tag | |||
) |
Name 'task'.
Notes:
Definition at line 2215 of file task.c.
References isc__task_setname(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, REQUIRE, and isc_taskmethods::setname.
Referenced by add_listener(), ATF_TC_BODY(), cache_cleaner_init(), client_create(), dispatch_createudp(), dns_acache_create(), dns_adb_create(), dns_cache_create3(), dns_dispatch_createtcp2(), dns_ntatable_create(), dns_resolver_create(), dns_view_createresolver(), dns_zonemgr_create(), dns_zonemgr_managezone(), isc_taskpool_create(), isc_taskpool_expand(), ns_lwdclientmgr_create(), ns_server_create(), and setup_libs().
unsigned int isc_task_purge | ( | isc_task_t * | task, | |
void * | sender, | |||
isc_eventtype_t | type, | |||
void * | tag | |||
) |
Purge events from a task's event queue.
Notes:
isc_task_purgerange(task, sender, type, type, tag); *
Requires:
Definition at line 2225 of file task.c.
References isc__task_purge(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, isc_taskmethods::purgeevents, and REQUIRE.
Referenced by acache_cleaner_shutdown_action(), and cleaner_shutdown_action().
isc_result_t isc_task_beginexclusive | ( | isc_task_t * | task | ) |
Request exclusive access for 'task', which must be the calling task. Waits for any other concurrently executing tasks to finish their current event, and prevents any new events from executing in any of the tasks sharing a task manager with 'task'.
The exclusive access must be relinquished by calling isc_task_endexclusive() before returning from the current event handler.
Requires:
Definition at line 2236 of file task.c.
References isc_taskmethods::beginexclusive, isc__task_beginexclusive(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, and REQUIRE.
Referenced by do_addzone(), do_modzone(), grow_entries(), grow_names(), interface_timer_tick(), load_configuration(), load_new_zones(), load_zones(), ns_clientmgr_destroy(), ns_server_delzone(), ns_server_flushcache(), ns_server_flushnode(), ns_server_freeze(), ns_server_nta(), ns_server_scan_interfaces(), ns_server_showzone(), ns_server_sync(), ns_server_tsigdelete(), ns_server_tsiglist(), ns_server_validation(), and shutdown_server().
void isc_task_endexclusive | ( | isc_task_t * | task | ) |
Relinquish the exclusive access obtained by isc_task_beginexclusive(), allowing other tasks to execute.
Requires:
Definition at line 2246 of file task.c.
References isc_taskmethods::endexclusive, isc__task_endexclusive(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, and REQUIRE.
Referenced by do_addzone(), do_modzone(), grow_entries(), grow_names(), interface_timer_tick(), load_configuration(), load_new_zones(), load_zones(), ns_clientmgr_destroy(), ns_server_delzone(), ns_server_flushcache(), ns_server_flushnode(), ns_server_freeze(), ns_server_nta(), ns_server_scan_interfaces(), ns_server_showzone(), ns_server_sync(), ns_server_tsigdelete(), ns_server_tsiglist(), ns_server_validation(), and shutdown_server().
void isc_task_setprivilege | ( | isc_task_t * | task, | |
isc_boolean_t | priv | |||
) |
Set or unset the task's "privileged" flag depending on the value of 'priv'.
Under normal circumstances this flag has no effect on the task behavior, but when the task manager has been set to privileged execution mode via isc_taskmgr_setmode(), only tasks with the flag set will be executed, and all other tasks will wait until they're done. Once all privileged tasks have finished executing, the task manager will automatically return to normal execution mode and nonprivileged task can resume.
Requires:
Definition at line 2256 of file task.c.
References isc__task_setprivilege(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, REQUIRE, and isc_taskmethods::setprivilege.
Referenced by ATF_TC_BODY(), and isc_taskpool_setprivilege().
isc_boolean_t isc_task_privilege | ( | isc_task_t * | task | ) |
Returns the current value of the task's privilege flag.
Requires:
Definition at line 2266 of file task.c.
References isc__task_privilege(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, isc_taskmethods::privilege, and REQUIRE.
Referenced by ATF_TC_BODY().
void isc_task_getcurrenttime | ( | isc_task_t * | task, | |
isc_stdtime_t * | t | |||
) |
Provide the most recent timestamp on the task. The timestamp is considered as the "current time" in the second-order granularity.
Requires:
Definition at line 2276 of file task.c.
References isc__task_getcurrenttime(), and isc_bind9.
Referenced by client_request().
unsigned int isc_task_purgerange | ( | isc_task_t * | task, | |
void * | sender, | |||
isc_eventtype_t | first, | |||
isc_eventtype_t | last, | |||
void * | tag | |||
) |
This is necessary for libisc's internal timer implementation. Other implementation might skip implementing this.
Purge events from a task's event queue.
Definition at line 2288 of file task.c.
References isc__task_purgerange(), isc_bind9, ISCAPI_TASK_VALID, isc_task::methods, isc_taskmethods::purgerange, and REQUIRE.
Referenced by destroy(), and isc__timer_reset().
isc__taskmgr_t* taskmgr = NULL [static] |
Definition at line 180 of file task.c.
Referenced by ATF_TC_BODY(), isc__taskmgr_create(), isc__taskmgr_destroy(), isc__taskmgr_dispatch(), isc__taskmgr_ready(), ISC_LIST(), main(), make_dispatchset(), manager_free(), set_and_drop(), waitbody(), and waitfor().
struct isc__taskmethods taskmethods [static] |
Referenced by isc__task_create().
isc_taskmgrmethods_t taskmgrmethods [static] |
Initial value:
{ isc__taskmgr_destroy, isc__taskmgr_setmode, isc__taskmgr_mode, isc__task_create, isc_taskmgr_setexcltask, isc_taskmgr_excltask }
Definition at line 293 of file task.c.
Referenced by isc__taskmgr_create().
isc_mutex_t createlock [static] |
isc_once_t once = ISC_ONCE_INIT [static] |
isc_taskmgrcreatefunc_t taskmgr_createfunc = NULL [static] |