The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Wrapper around libkqueue to make managing events easier. More...
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/lst.h>
#include <freeradius-devel/util/log.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/token.h>
#include <freeradius-devel/util/atexit.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <pthread.h>
Go to the source code of this file.
Data Structures | |
struct | fr_event_fd |
A file descriptor/filter event. More... | |
struct | fr_event_func_map_entry_t |
Specifies a mapping between a function pointer in a structure and its respective event. More... | |
struct | fr_event_func_map_t |
struct | fr_event_list |
Stores all information relating to an event list. More... | |
struct | fr_event_pid |
struct | fr_event_pid.early_exit |
Fields that are only used if we're being triggered by a user event. More... | |
struct | fr_event_pid_reap_t |
Hold additional information for automatically reaped PIDs. More... | |
struct | fr_event_post_t |
Callbacks to perform after all timers and FDs have been checked. More... | |
struct | fr_event_pre_t |
Callbacks to perform when the event handler is about to check the events. More... | |
struct | fr_event_timer |
A timer event. More... | |
struct | fr_event_user_s |
Callbacks for kevent() user events. More... | |
Macros | |
#define | EVENT_DEBUG(...) |
#define | FR_EV_BATCH_FDS (256) |
#define | FR_EVENT_FD_PCAP 0 |
#define | fr_time() static_assert(0, "Use el->time for event loop timing") |
#define | GET_FUNC(_ef, _offset) *((fr_event_fd_cb_t const *)((uint8_t const *)&(_ef)->active + _offset)) |
#define | NOTE_EXITSTATUS (0) |
Enumerations | |
enum | fr_event_fd_type_t { FR_EVENT_FD_SOCKET = 1 , FR_EVENT_FD_FILE = 2 , FR_EVENT_FD_DIRECTORY = 4 } |
enum | fr_event_func_idx_type_t { FR_EVENT_FUNC_IDX_NONE = 0 , FR_EVENT_FUNC_IDX_FILTER , FR_EVENT_FUNC_IDX_FFLAGS } |
Functions | |
static int | _event_build_indexes (UNUSED void *uctx) |
static int | _event_fd_delete (fr_event_fd_t *ef) |
Remove a file descriptor from the event loop and rbtree but don't explicitly free it. More... | |
static int | _event_free_indexes (UNUSED void *uctx) |
Free any memory we allocated for indexes. More... | |
static int | _event_list_free (fr_event_list_t *el) |
Cleanup an event list. More... | |
static int | _event_pid_free (fr_event_pid_t *ev) |
Remove PID wait event from kevent if the fr_event_pid_t is freed. More... | |
static int | _event_timer_free (fr_event_timer_t *ev) |
Remove an event from the event loop. More... | |
static int | _event_user_delete (fr_event_user_t *ev) |
Memory will not be freed if we fail to remove the event from the kqueue. More... | |
int | _fr_event_fd_insert (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_event_fd_t **ef_out, fr_event_list_t *el, int fd, fr_event_fd_cb_t read_fn, fr_event_fd_cb_t write_fn, fr_event_error_cb_t error, void *uctx) |
Associate I/O callbacks with a file descriptor. More... | |
int | _fr_event_fd_move (NDEBUG_LOCATION_ARGS fr_event_list_t *dst, fr_event_list_t *src, int fd, fr_event_filter_t filter) |
Move a file descriptor event from one event list to another. More... | |
int | _fr_event_filter_insert (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_event_fd_t **ef_out, fr_event_list_t *el, int fd, fr_event_filter_t filter, void *funcs, fr_event_error_cb_t error, void *uctx) |
Insert a filter for the specified fd. More... | |
int | _fr_event_filter_update (NDEBUG_LOCATION_ARGS fr_event_list_t *el, int fd, fr_event_filter_t filter, fr_event_update_t const updates[]) |
Suspend/resume a subset of filters. More... | |
static void | _fr_event_pid_early_exit (fr_event_list_t *el, void *uctx) |
Called on the next loop through the event loop when inserting an EVFILT_PROC event fails. More... | |
int | _fr_event_pid_reap (NDEBUG_LOCATION_ARGS fr_event_list_t *el, pid_t pid, fr_event_pid_cb_t callback, void *uctx) |
Asynchronously wait for a PID to exit, then reap it. More... | |
static void | _fr_event_pid_reap_cb (UNUSED fr_event_list_t *el, pid_t pid, int status, void *uctx) |
Does the actual reaping of PIDs. More... | |
int | _fr_event_pid_wait (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_event_list_t *el, fr_event_pid_t const **ev_p, pid_t pid, fr_event_pid_cb_t callback, void *uctx) |
Insert a PID event into an event list. More... | |
static int | _fr_event_reap_free (fr_event_pid_reap_t *reap) |
int | _fr_event_timer_at (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_event_list_t *el, fr_event_timer_t const **ev_p, fr_time_t when, fr_event_timer_cb_t callback, void const *uctx) |
Insert a timer event into an event list. More... | |
int | _fr_event_timer_in (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_event_list_t *el, fr_event_timer_t const **ev_p, fr_time_delta_t delta, fr_event_timer_cb_t callback, void const *uctx) |
Insert a timer event into an event list. More... | |
int | _fr_event_user_insert (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_event_list_t *el, fr_event_user_t **ev_p, bool trigger, fr_event_user_cb_t callback, void *uctx) |
Add a user callback to the event list. More... | |
static void | event_callback (fr_event_list_t *el, fr_event_fd_t *ef, int *filter, int flags, int *fflags) |
EVENT_DEBUG ("%s - Reaper forcefully reaping PID %u - %p", __FUNCTION__, reap->pid_ev->pid, reap) | |
static fr_event_fd_cb_t | event_fd_func (fr_event_fd_t *ef, int *filter, int *fflags) |
Figure out which function to call given a kevent. More... | |
static void | event_fd_func_index_build (fr_event_func_map_t *map) |
static void | event_list_reap_run_callback (fr_event_pid_reap_t *reap, pid_t pid, int status) |
Saves some boilerplate... More... | |
event_list_reap_run_callback (reap, reap->pid_ev->pid, status) | |
static void | event_pid_eval (fr_event_list_t *el, struct kevent *kev) |
Evaluate a EVFILT_PROC event. More... | |
static void | event_user_eval (fr_event_list_t *el, struct kevent *kev) |
static ssize_t | fr_event_build_evset (UNUSED fr_event_list_t *el, struct kevent out_kev[], size_t outlen, fr_event_funcs_t *active, fr_event_fd_t *ef, fr_event_funcs_t const *new, fr_event_funcs_t const *prev) |
Build a new evset based on function pointers present. More... | |
int | fr_event_corral (fr_event_list_t *el, fr_time_t now, bool wait) |
Gather outstanding timer and file descriptor events. More... | |
int | fr_event_fd_armour (fr_event_list_t *el, int fd, fr_event_filter_t filter, uintptr_t armour) |
Armour an FD. More... | |
fr_event_fd_cb_t | fr_event_fd_cb (fr_event_fd_t *ef, int kq_filter, int kq_fflags) |
Returns the appropriate callback function for a given event. More... | |
static int8_t | fr_event_fd_cmp (void const *one, void const *two) |
Compare two file descriptor handles. More... | |
int | fr_event_fd_delete (fr_event_list_t *el, int fd, fr_event_filter_t filter) |
Remove a file descriptor from the event loop. More... | |
fr_event_fd_t * | fr_event_fd_handle (fr_event_list_t *el, int fd, fr_event_filter_t filter) |
Get the opaque event handle from a file descriptor. More... | |
static void | fr_event_fd_noop (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, UNUSED void *uctx) |
Placeholder callback to avoid branches in service loop. More... | |
static int | fr_event_fd_type_set (fr_event_fd_t *ef, int fd) |
Discover the type of a file descriptor. More... | |
void * | fr_event_fd_uctx (fr_event_fd_t *ef) |
Returns the uctx associated with an fr_event_fd_t handle. More... | |
int | fr_event_fd_unarmour (fr_event_list_t *el, int fd, fr_event_filter_t filter, uintptr_t armour) |
Unarmour an FD. More... | |
fr_event_list_t * | fr_event_list_alloc (TALLOC_CTX *ctx, fr_event_status_cb_t status, void *status_uctx) |
Initialise a new event list. More... | |
bool | fr_event_list_empty (fr_event_list_t *el) |
Return whether the event loop has any active events. More... | |
int | fr_event_list_kq (fr_event_list_t *el) |
Return the kq associated with an event list. More... | |
uint64_t | fr_event_list_num_fds (fr_event_list_t *el) |
Return the number of file descriptors is_registered with this event loop. More... | |
uint64_t | fr_event_list_num_timers (fr_event_list_t *el) |
Return the number of timer events currently scheduled. More... | |
unsigned int | fr_event_list_reap_signal (fr_event_list_t *el, fr_time_delta_t timeout, int signal) |
Send a signal to all the processes we have in our reap list, and reap them. More... | |
void | fr_event_list_set_time_func (fr_event_list_t *el, fr_event_time_source_t func) |
Override event list time source. More... | |
fr_time_t | fr_event_list_time (fr_event_list_t *el) |
Get the current server time according to the event list. More... | |
int | fr_event_loop (fr_event_list_t *el) |
Run an event loop. More... | |
void | fr_event_loop_exit (fr_event_list_t *el, int code) |
Signal an event loop exit with the specified code. More... | |
bool | fr_event_loop_exiting (fr_event_list_t *el) |
Check to see whether the event loop is in the process of exiting. More... | |
int | fr_event_post_delete (fr_event_list_t *el, fr_event_timer_cb_t callback, void *uctx) |
Delete a post-event callback from the event list. More... | |
int | fr_event_post_insert (fr_event_list_t *el, fr_event_timer_cb_t callback, void *uctx) |
Add a post-event callback to the event list. More... | |
int | fr_event_pre_delete (fr_event_list_t *el, fr_event_status_cb_t callback, void *uctx) |
Delete a pre-event callback from the event list. More... | |
int | fr_event_pre_insert (fr_event_list_t *el, fr_event_status_cb_t callback, void *uctx) |
Add a pre-event callback to the event list. More... | |
void | fr_event_service (fr_event_list_t *el) |
Service any outstanding timer or file descriptor events. More... | |
static int8_t | fr_event_timer_cmp (void const *a, void const *b) |
Compare two timer events to see which one should occur first. More... | |
int | fr_event_timer_delete (fr_event_timer_t const **ev_p) |
Delete a timer event from the event list. More... | |
int | fr_event_timer_run (fr_event_list_t *el, fr_time_t *when) |
Run a single scheduled timer event. More... | |
fr_time_t | fr_event_timer_when (fr_event_timer_t const *ev) |
Internal timestamp representing when the timer should fire. More... | |
int | fr_event_user_trigger (fr_event_list_t *el, fr_event_user_t *ev) |
Trigger a user event. More... | |
if (kill(reap->pid_ev->pid, signal)< 0) | |
talloc_free (reap) | |
waitpid (reap->pid_ev->pid, &status, 0) | |
Variables | |
force | __pad0__ |
static fr_event_func_map_t | filter_maps [] |
static fr_table_num_sorted_t const | fr_event_fd_type_table [] |
static size_t | fr_event_fd_type_table_len = NUM_ELEMENTS(fr_event_fd_type_table) |
static fr_table_num_sorted_t const | kevent_filter_table [] |
static size_t | kevent_filter_table_len = NUM_ELEMENTS(kevent_filter_table) |
return | processed |
Wrapper around libkqueue to make managing events easier.
Non-thread-safe event handling specific to FreeRADIUS.
By non-thread-safe we mean multiple threads can't insert/delete events concurrently into the same event list without synchronization.
Definition in file event.c.
struct fr_event_fd |
Data Fields | ||
---|---|---|
fr_event_funcs_t | active | Active filter functions. |
uintptr_t | armour | protection flag from being deleted. |
fr_event_list_t * | el | Event list this event belongs to. |
fr_dlist_t | entry | Entry in free list. |
fr_event_error_cb_t | error | Callback for when an error occurs on the FD. |
int | fd | File descriptor we're listening for events on. |
char const * | file | Source file this event was last updated in. |
fr_event_filter_t | filter | |
bool | is_registered |
Whether this fr_event_fd_t's FD has been registered with kevent. Mostly for debugging. |
int | line | Line this event was last updated on. |
TALLOC_CTX * | linked_ctx | talloc ctx this event was bound to. |
fr_event_func_map_t const * | map | Function map between fr_event_funcs_t and kevent filters. |
fr_rb_node_t | node |
Entry in the tree of file descriptor handles. this should really go away and we should pass around handles directly. |
int | sock_type | The type of socket SOCK_STREAM, SOCK_RAW etc... |
fr_event_funcs_t | stored | Stored (set, but inactive) filter functions. |
fr_event_fd_type_t | type | Type of events we're interested in. |
void * | uctx | Context pointer to pass to each file descriptor callback. |
struct fr_event_func_map_entry_t |
Specifies a mapping between a function pointer in a structure and its respective event.
If the function pointer at the specified offset is set, then a matching event will be added.
If the function pointer is NULL, then any existing events will be removed.
Data Fields | ||
---|---|---|
bool | coalesce | Coalesce this map with the next. |
uint32_t | fflags | fflags to pass to filter. |
int16_t | filter | Filter to apply. |
uint16_t | flags | Flags to use for inserting event. |
char const * | name | Name of the event. |
size_t | offset | Offset of function pointer in structure. |
int | type | Type this filter applies to. |
struct fr_event_func_map_t |
Data Fields | ||
---|---|---|
fr_event_func_map_entry_t ** | ev_to_func | Function -> Event maps in index order. |
fr_event_func_map_entry_t * | func_to_ev | Function -> Event maps coalesced, out of order. |
fr_event_func_idx_type_t | idx_type | What type of index we use for event to function mapping. |
struct fr_event_list |
Data Fields | ||
---|---|---|
bool | dispatch | Whether the event list is currently dispatching events. |
fr_dlist_head_t | ev_to_add | dlist of events to add |
struct kevent | events[FR_EV_BATCH_FDS] | |
int | exit | If non-zero event loop will prevent the addition of new events, and will return immediately from the corral/service function. |
fr_dlist_head_t | fd_to_free | File descriptor events pending deletion. |
fr_rb_tree_t * | fds | Tree used to track FDs with filters in kqueue. |
bool | in_handler | Deletes should be deferred until after the handlers complete. |
int | kq | instance associated with this event list. |
fr_time_t | now | The last time the event list was serviced. |
int | num_fd_events | Number of events in this event list. |
fr_dlist_head_t | pid_to_reap | A list of all orphaned child processes we're waiting to reap. |
fr_dlist_head_t | post_callbacks | post-processing callbacks |
fr_dlist_head_t | pre_callbacks | callbacks when we may be idle... |
fr_event_time_source_t | time | Where our time comes from. |
fr_lst_t * | times | of timer events to be executed. |
int | will_exit | Will exit on next call to fr_event_corral. |
struct fr_event_pid |
Data Fields | ||
---|---|---|
fr_event_pid_cb_t | callback | callback to run when the child exits |
struct fr_event_pid | early_exit | Fields that are only used if we're being triggered by a user event. |
fr_event_list_t * | el | Event list this event belongs to. |
char const * | file | Source file this event was last updated in. |
bool | is_registered | Whether this user event has been registered with the event loop. |
int | line | Line this event was last updated on. |
fr_event_pid_t const ** | parent | |
pid_t | pid | child to wait for |
void * | uctx | Context pointer to pass to each file descriptor callback. |
struct fr_event_pid.early_exit |
Fields that are only used if we're being triggered by a user event.
Data Fields | ||
---|---|---|
fr_event_user_t * | ev | Fallback user event we use to raise a PID event when a race occurs with kevent. |
int | status | Status we got from waitid. |
struct fr_event_pid_reap_t |
Data Fields | ||
---|---|---|
fr_event_pid_cb_t | callback | callback to run when the child exits |
fr_event_list_t * | el | Event list this event belongs to. |
fr_dlist_t | entry |
If the fr_event_pid is in the detached, reap state, it's inserted into a list associated with the event. We then send SIGKILL, and forcefully reap the process on exit. |
fr_event_pid_t const * | pid_ev | pid_ev this reaper is bound to. |
void * | uctx | Context pointer to pass to each file descriptor callback. |
struct fr_event_post_t |
Callbacks to perform after all timers and FDs have been checked.
Data Fields | ||
---|---|---|
fr_event_timer_cb_t | callback | The callback to call. |
fr_dlist_t | entry | Linked list of callback. |
void * | uctx | Context for the callback. |
struct fr_event_pre_t |
Callbacks to perform when the event handler is about to check the events.
Data Fields | ||
---|---|---|
fr_event_status_cb_t | callback | The callback to call. |
fr_dlist_t | entry | Linked list of callback. |
void * | uctx | Context for the callback. |
struct fr_event_timer |
Data Fields | ||
---|---|---|
fr_event_timer_cb_t | callback | Callback to execute when the timer fires. |
fr_event_list_t * | el | Event list containing this timer. |
fr_dlist_t | entry | List of deferred timer events. |
char const * | file | Source file this event was last updated in. |
int | line | Line this event was last updated on. |
TALLOC_CTX * | linked_ctx | talloc ctx this event was bound to. |
fr_lst_index_t | lst_id | Where to store opaque lst data. |
fr_event_timer_t const ** | parent | A pointer to the parent structure containing the timer event. |
void const * | uctx | Context pointer to pass to the callback. |
fr_time_t | when | When this timer should fire. |
struct fr_event_user_s |
Data Fields | ||
---|---|---|
fr_event_user_cb_t | callback | The callback to call. |
fr_event_list_t * | el | Event list this event belongs to. |
char const * | file | Source file this event was last updated in. |
bool | is_registered | Whether this user event has been registered with the event loop. |
int | line | Line this event was last updated on. |
void * | uctx | Context for the callback. |
#define fr_time | ( | void | ) | static_assert(0, "Use el->time for event loop timing") |
#define GET_FUNC | ( | _ef, | |
_offset | |||
) | *((fr_event_fd_cb_t const *)((uint8_t const *)&(_ef)->active + _offset)) |
#define NOTE_EXITSTATUS (0) |
enum fr_event_fd_type_t |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Memory will not be freed if we fail to remove the event from the kqueue.
It's easier to debug memory leaks with modern tooling than it is to determine why we get random failures and event leaks inside of kqueue.
Definition at line 2141 of file event.c.
int _fr_event_fd_insert | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_event_fd_t ** | ef_out, | ||
fr_event_list_t * | el, | ||
int | fd, | ||
fr_event_fd_cb_t | read_fn, | ||
fr_event_fd_cb_t | write_fn, | ||
fr_event_error_cb_t | error, | ||
void * | uctx | ||
) |
Associate I/O callbacks with a file descriptor.
[in] | ctx | to bind lifetime of the event to. |
[out] | ef_out | Where to store the output event |
[in] | el | to insert fd callback into. |
[in] | fd | to install filters for. |
[in] | read_fn | function to call when fd is readable. |
[in] | write_fn | function to call when fd is writable. |
[in] | error | function to call when an error occurs on the fd. |
[in] | uctx | to pass to handler. |
Definition at line 1233 of file event.c.
int _fr_event_fd_move | ( | NDEBUG_LOCATION_ARGS fr_event_list_t * | dst, |
fr_event_list_t * | src, | ||
int | fd, | ||
fr_event_filter_t | filter | ||
) |
Move a file descriptor event from one event list to another.
FIXME - Move suspended events too.
[in] | dst | Event list to move file descriptor event to. |
[in] | src | Event list to move file descriptor from. |
[in] | fd | of the event to move. |
[in] | filter | of the event to move. |
Definition at line 949 of file event.c.
int _fr_event_filter_insert | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_event_fd_t ** | ef_out, | ||
fr_event_list_t * | el, | ||
int | fd, | ||
fr_event_filter_t | filter, | ||
void * | funcs, | ||
fr_event_error_cb_t | error, | ||
void * | uctx | ||
) |
Insert a filter for the specified fd.
[in] | ctx | to bind lifetime of the event to. |
[out] | ef_out | Previously allocated ef, or NULL. |
[in] | el | to insert fd callback into. |
[in] | fd | to install filters for. |
[in] | filter | one of the fr_event_filter_t values. |
[in] | funcs | Structure containing callback functions. If a function pointer is set, the equivalent kevent filter will be installed. |
[in] | error | function to call when an error occurs on the fd. |
[in] | uctx | to pass to handler. |
Definition at line 1077 of file event.c.
int _fr_event_filter_update | ( | NDEBUG_LOCATION_ARGS fr_event_list_t * | el, |
int | fd, | ||
fr_event_filter_t | filter, | ||
fr_event_update_t const | updates[] | ||
) |
Suspend/resume a subset of filters.
This function trades producing useful errors for speed.
An example of suspending the read filter for an FD would be:
[in] | el | to update descriptor in. |
[in] | fd | to update filters for. |
[in] | filter | The type of filter to update. |
[in] | updates | An array of updates to toggle filters on/off without removing the callback function. |
Definition at line 1000 of file event.c.
|
static |
Called on the next loop through the event loop when inserting an EVFILT_PROC event fails.
This is just a trampoleen function which takes the user event and simulates an EVFILT_PROC event from it.
[in] | el | That received the event. |
[in] | uctx | An fr_event_pid_t to process. |
Definition at line 1710 of file event.c.
int _fr_event_pid_reap | ( | NDEBUG_LOCATION_ARGS fr_event_list_t * | el, |
pid_t | pid, | ||
fr_event_pid_cb_t | callback, | ||
void * | uctx | ||
) |
Asynchronously wait for a PID to exit, then reap it.
This is intended to be used when we no longer care about a process exiting, but we still want to clean up its state so we don't have zombie processes sticking around.
[in] | el | to use to reap the process. |
[in] | pid | to reap. |
[in] | callback | to call when the process is reaped. May be NULL. |
[in] | uctx | to pass to callback. |
Definition at line 1968 of file event.c.
|
static |
int _fr_event_pid_wait | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_event_list_t * | el, | ||
fr_event_pid_t const ** | ev_p, | ||
pid_t | pid, | ||
fr_event_pid_cb_t | callback, | ||
void * | uctx | ||
) |
Insert a PID event into an event list.
[in] | ctx | to bind lifetime of the event to. |
[in] | el | to insert event into. |
[in,out] | ev_p | If not NULL modify this event instead of creating a new one. This is a parent in a temporal sense, not in a memory structure or dependency sense. |
[in] | pid | child PID to wait for |
[in] | callback | function to execute if the event fires. |
[in] | uctx | user data to pass to the event. |
Definition at line 1741 of file event.c.
|
static |
int _fr_event_timer_at | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_event_list_t * | el, | ||
fr_event_timer_t const ** | ev_p, | ||
fr_time_t | when, | ||
fr_event_timer_cb_t | callback, | ||
void const * | uctx | ||
) |
Insert a timer event into an event list.
[in] | ctx | to bind lifetime of the event to. |
[in] | el | to insert event into. |
[in,out] | ev_p | If not NULL modify this event instead of creating a new one. This is a parent in a temporal sense, not in a memory structure or dependency sense. |
[in] | when | we should run the event. |
[in] | callback | function to execute if the event fires. |
[in] | uctx | user data to pass to the event. |
Definition at line 1451 of file event.c.
int _fr_event_timer_in | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_event_list_t * | el, | ||
fr_event_timer_t const ** | ev_p, | ||
fr_time_delta_t | delta, | ||
fr_event_timer_cb_t | callback, | ||
void const * | uctx | ||
) |
Insert a timer event into an event list.
[in] | ctx | to bind lifetime of the event to. |
[in] | el | to insert event into. |
[in,out] | ev_p | If not NULL modify this event instead of creating a new one. This is a parent in a temporal sense, not in a memory structure or dependency sense. |
[in] | delta | In how many nanoseconds to wait before should we execute the event. |
[in] | callback | function to execute if the event fires. |
[in] | uctx | user data to pass to the event. |
Definition at line 1596 of file event.c.
int _fr_event_user_insert | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_event_list_t * | el, | ||
fr_event_user_t ** | ev_p, | ||
bool | trigger, | ||
fr_event_user_cb_t | callback, | ||
void * | uctx | ||
) |
Add a user callback to the event list.
[in] | ctx | to allocate the event in. |
[in] | el | Containing the timer events. |
[out] | ev_p | Where to write a pointer. |
[in] | trigger | Whether the user event is triggered initially. |
[in] | callback | for EVFILT_USER. |
[in] | uctx | for the callback. |
Definition at line 2187 of file event.c.
|
inlinestatic |
EVENT_DEBUG | ( | "%s - Reaper forcefully reaping PID %u - %p" | , |
__FUNCTION__ | , | ||
reap->pid_ev-> | pid, | ||
reap | |||
) |
|
inlinestatic |
Figure out which function to call given a kevent.
This function should be called in a loop until it returns NULL.
[in] | ef | File descriptor state handle. |
[in] | filter | from the kevent. |
[in,out] | fflags | from the kevent. Each call will return the function from the next most significant NOTE_*, with each NOTE_* before unset from fflags. |
Definition at line 529 of file event.c.
|
static |
|
inlinestatic |
event_list_reap_run_callback | ( | reap | , |
reap->pid_ev-> | pid, | ||
status | |||
) |
|
inlinestatic |
|
inlinestatic |
|
static |
Build a new evset based on function pointers present.
[in] | el | we're building events for. |
[out] | out_kev | where to write the evset. |
[in] | outlen | length of output buffer. |
[out] | active | The set of function pointers with active filters. |
[in] | ef | event to insert. |
[in] | new | Functions to map to filters. |
[in] | prev | Previous set of functions mapped to filters. |
Definition at line 678 of file event.c.
int fr_event_corral | ( | fr_event_list_t * | el, |
fr_time_t | now, | ||
bool | wait | ||
) |
Gather outstanding timer and file descriptor events.
[in] | el | to process events for. |
[in] | now | The current time. |
[in] | wait | if true, block on the kevent() call until a timer or file descriptor event occurs. |
Definition at line 2414 of file event.c.
int fr_event_fd_armour | ( | fr_event_list_t * | el, |
int | fd, | ||
fr_event_filter_t | filter, | ||
uintptr_t | armour | ||
) |
Armour an FD.
[in] | el | to remove file descriptor from. |
[in] | fd | to remove. |
[in] | filter | The type of filter to remove. |
[in] | armour | The armour to add. |
Definition at line 1342 of file event.c.
fr_event_fd_cb_t fr_event_fd_cb | ( | fr_event_fd_t * | ef, |
int | kq_filter, | ||
int | kq_fflags | ||
) |
Returns the appropriate callback function for a given event.
[in] | ef | the event filter fd handle. |
[in] | kq_filter | If the callbacks are indexed by filter. |
[in] | kq_fflags | If the callbacks are indexed by NOTES (fflags). |
Definition at line 1318 of file event.c.
|
static |
Compare two file descriptor handles.
[in] | one | the first file descriptor handle. |
[in] | two | the second file descriptor handle. |
Definition at line 589 of file event.c.
int fr_event_fd_delete | ( | fr_event_list_t * | el, |
int | fd, | ||
fr_event_filter_t | filter | ||
) |
Remove a file descriptor from the event loop.
[in] | el | to remove file descriptor from. |
[in] | fd | to remove. |
[in] | filter | The type of filter to remove. |
Definition at line 1260 of file event.c.
fr_event_fd_t* fr_event_fd_handle | ( | fr_event_list_t * | el, |
int | fd, | ||
fr_event_filter_t | filter | ||
) |
Get the opaque event handle from a file descriptor.
[in] | el | to search for fd/filter in. |
[in] | fd | to search for. |
[in] | filter | to search for. |
Definition at line 1296 of file event.c.
|
static |
|
static |
Discover the type of a file descriptor.
This function writes the result of the discovery to the ef->type, and ef->sock_type fields.
[out] | ef | to write type data to. |
[in] | fd | to discover the type of. |
Definition at line 811 of file event.c.
void* fr_event_fd_uctx | ( | fr_event_fd_t * | ef | ) |
int fr_event_fd_unarmour | ( | fr_event_list_t * | el, |
int | fd, | ||
fr_event_filter_t | filter, | ||
uintptr_t | armour | ||
) |
Unarmour an FD.
[in] | el | to remove file descriptor from. |
[in] | fd | to remove. |
[in] | filter | The type of filter to remove. |
[in] | armour | The armour to remove |
Definition at line 1372 of file event.c.
fr_event_list_t* fr_event_list_alloc | ( | TALLOC_CTX * | ctx, |
fr_event_status_cb_t | status, | ||
void * | status_uctx | ||
) |
Initialise a new event list.
[in] | ctx | to allocate memory in. |
[in] | status | callback, called on each iteration of the event list. |
[in] | status_uctx | context for the status callback |
Definition at line 2899 of file event.c.
bool fr_event_list_empty | ( | fr_event_list_t * | el | ) |
int fr_event_list_kq | ( | fr_event_list_t * | el | ) |
uint64_t fr_event_list_num_fds | ( | fr_event_list_t * | el | ) |
uint64_t fr_event_list_num_timers | ( | fr_event_list_t * | el | ) |
unsigned int fr_event_list_reap_signal | ( | fr_event_list_t * | el, |
fr_time_delta_t | timeout, | ||
int | signal | ||
) |
Send a signal to all the processes we have in our reap list, and reap them.
[in] | el | containing the processes to reap. |
[in] | timeout | how long to wait before we signal the processes. |
[in] | signal | to send to processes. Should be a fatal signal. |
Definition at line 2004 of file event.c.
void fr_event_list_set_time_func | ( | fr_event_list_t * | el, |
fr_event_time_source_t | func | ||
) |
fr_time_t fr_event_list_time | ( | fr_event_list_t * | el | ) |
Get the current server time according to the event list.
If the event list is currently dispatching events, we return the time this iteration of the event list started.
If the event list is not currently dispatching events, we return the current system time.
[in] | el | to get time from. |
Definition at line 643 of file event.c.
int fr_event_loop | ( | fr_event_list_t * | el | ) |
Run an event loop.
[in] | el | to start processing. |
Definition at line 2766 of file event.c.
void fr_event_loop_exit | ( | fr_event_list_t * | el, |
int | code | ||
) |
Signal an event loop exit with the specified code.
The event loop will complete its current iteration, and then exit with the specified code.
[in] | el | to signal to exit. |
[in] | code | for fr_event_loop to return. |
Definition at line 2744 of file event.c.
bool fr_event_loop_exiting | ( | fr_event_list_t * | el | ) |
int fr_event_post_delete | ( | fr_event_list_t * | el, |
fr_event_timer_cb_t | callback, | ||
void * | uctx | ||
) |
Delete a post-event callback from the event list.
[in] | el | Containing the timer events. |
[in] | callback | The post-processing callback. |
[in] | uctx | for the callback. |
Definition at line 2335 of file event.c.
int fr_event_post_insert | ( | fr_event_list_t * | el, |
fr_event_timer_cb_t | callback, | ||
void * | uctx | ||
) |
Add a post-event callback to the event list.
Events are serviced in insert order. i.e. insert A, B, we then have A running before B.
[in] | el | Containing the timer events. |
[in] | callback | The post-processing callback. |
[in] | uctx | for the callback. |
Definition at line 2313 of file event.c.
int fr_event_pre_delete | ( | fr_event_list_t * | el, |
fr_event_status_cb_t | callback, | ||
void * | uctx | ||
) |
Delete a pre-event callback from the event list.
[in] | el | Containing the timer events. |
[in] | callback | The pre-processing callback. |
[in] | uctx | for the callback. |
Definition at line 2281 of file event.c.
int fr_event_pre_insert | ( | fr_event_list_t * | el, |
fr_event_status_cb_t | callback, | ||
void * | uctx | ||
) |
Add a pre-event callback to the event list.
Events are serviced in insert order. i.e. insert A, B, we then have A running before B.
[in] | el | Containing the timer events. |
[in] | callback | The pre-processing callback. |
[in] | uctx | for the callback. |
Definition at line 2259 of file event.c.
void fr_event_service | ( | fr_event_list_t * | el | ) |
|
static |
Compare two timer events to see which one should occur first.
[in] | a | the first timer event. |
[in] | b | the second timer event. |
Definition at line 576 of file event.c.
int fr_event_timer_delete | ( | fr_event_timer_t const ** | ev_p | ) |
int fr_event_timer_run | ( | fr_event_list_t * | el, |
fr_time_t * | when | ||
) |
Run a single scheduled timer event.
[in] | el | containing the timer events. |
[in] | when | Process events scheduled to run before or at this time. |
Definition at line 2363 of file event.c.
fr_time_t fr_event_timer_when | ( | fr_event_timer_t const * | ev | ) |
int fr_event_user_trigger | ( | fr_event_list_t * | el, |
fr_event_user_t * | ev | ||
) |
talloc_free | ( | reap | ) |
waitpid | ( | reap->pid_ev-> | pid, |
& | status, | ||
0 | |||
) |
|
static |
|
static |
|
static |
|
static |
|
static |