The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
event.h File Reference

Wrapper around libkqueue to make managing events easier. More...

#include <freeradius-devel/util/timer.h>
#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/time.h>
#include <freeradius-devel/util/talloc.h>
#include <stdbool.h>
#include <sys/event.h>
+ Include dependency graph for event.h:

Go to the source code of this file.

Data Structures

union  fr_event_funcs_t
 Union of all filter functions. More...
 
struct  fr_event_io_func_t
 Callbacks for the FR_EVENT_FILTER_IO filter. More...
 
struct  fr_event_list_pub_s
 Public event list structure. More...
 
struct  fr_event_update_t
 Structure describing a modification to a filter's state. More...
 
struct  fr_event_vnode_func_t
 Callbacks for the FR_EVENT_FILTER_VNODE filter. More...
 

Macros

#define EVENT_DEBUG(...)
 
#define fr_event_fd_insert(...)   _fr_event_fd_insert(NDEBUG_LOCATION_EXP __VA_ARGS__)
 
#define fr_event_fd_mode(...)   _fr_event_fd_move(NDEBUG_LOCATION_EXP __VA_ARGS__)
 
#define fr_event_filter_insert(...)   _fr_event_filter_insert(NDEBUG_LOCATION_EXP __VA_ARGS__)
 
#define fr_event_filter_update(...)   _fr_event_filter_update(NDEBUG_LOCATION_EXP __VA_ARGS__)
 
#define fr_event_pid_reap(...)   _fr_event_pid_reap(NDEBUG_LOCATION_EXP __VA_ARGS__)
 
#define fr_event_pid_wait(...)   _fr_event_pid_wait(NDEBUG_LOCATION_EXP __VA_ARGS__)
 
#define FR_EVENT_RESUME(_s, _f)   { .offset = offsetof(_s, _f), .op = FR_EVENT_OP_RESUME }
 Re-add the filter for a func from kevent.
 
#define FR_EVENT_SUSPEND(_s, _f)   { .offset = offsetof(_s, _f), .op = FR_EVENT_OP_SUSPEND }
 Temporarily remove the filter for a func from kevent.
 
#define fr_event_user_insert(_ctx, _ev_p, _el, _trigger, _callback, _uctx)    _fr_event_user_insert(NDEBUG_LOCATION_EXP _ctx, _ev_p, _el, _trigger, _callback, _uctx)
 

Typedefs

typedef void(* fr_event_error_cb_t) (fr_event_list_t *el, int fd, int flags, int fd_errno, void *uctx)
 Called when an IO error event occurs on a file descriptor.
 
typedef void(* fr_event_fd_cb_t) (fr_event_list_t *el, int fd, int flags, void *uctx)
 Called when an IO event occurs on a file descriptor.
 
typedef struct fr_event_fd fr_event_fd_t
 An opaque file descriptor handle.
 
typedef struct fr_event_list_pub_s fr_event_list_t
 
typedef void(* fr_event_pid_cb_t) (fr_event_list_t *el, pid_t pid, int status, void *uctx)
 Called when a child process has exited.
 
typedef struct fr_event_pid fr_event_pid_t
 An opaque PID status handle.
 
typedef void(* fr_event_post_cb_t) (fr_event_list_t *el, fr_time_t now, void *uctx)
 Called when a post event fires.
 
typedef int(* fr_event_status_cb_t) (fr_time_t now, fr_time_delta_t wake, void *uctx)
 Called after each event loop cycle.
 
typedef void(* fr_event_user_cb_t) (fr_event_list_t *el, void *uctx)
 Called when a user kevent occurs.
 
typedef struct fr_event_user_s fr_event_user_t
 An opaque user event handle.
 

Enumerations

enum  fr_event_filter_t {
  FR_EVENT_FILTER_IO = 1 ,
  FR_EVENT_FILTER_VNODE
}
 The type of filter to install for an FD. More...
 
enum  fr_event_op_t {
  FR_EVENT_OP_SUSPEND = 1 ,
  FR_EVENT_OP_RESUME
}
 Operations to perform on filter. More...
 

Functions

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.
 
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.
 
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.
 
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.
 
int _fr_event_pid_reap (NDEBUG_LOCATION_ARGS fr_event_list_t *el, pid_t pid, fr_event_pid_cb_t wait_fn, void *uctx)))
 Asynchronously wait for a PID to exit, then reap it.
 
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 wait_fn, void *uctx)))
 Insert a PID event into an event list.
 
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.
 
int fr_event_corral (fr_event_list_t *el, fr_time_t now, bool wait)
 Gather outstanding timer and file descriptor events.
 
int fr_event_fd_armour (fr_event_list_t *el, int fd, fr_event_filter_t, uintptr_t armour)
 Armour an FD.
 
fr_event_fd_cb_t fr_event_fd_cb (fr_event_fd_t *ef, int filter, int fflags)
 Returns the appropriate callback function for a given event.
 
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.
 
fr_event_fd_tfr_event_fd_handle (fr_event_list_t *el, int fd, fr_event_filter_t filter)
 Get the opaque event handle from a file descriptor.
 
void * fr_event_fd_uctx (fr_event_fd_t *ef)
 Returns the uctx associated with an fr_event_fd_t handle.
 
int fr_event_fd_unarmour (fr_event_list_t *el, int fd, fr_event_filter_t filter, uintptr_t armour)
 Unarmour an FD.
 
fr_event_list_tfr_event_list_alloc (TALLOC_CTX *ctx, fr_event_status_cb_t status, void *status_ctx)
 Initialise a new event list.
 
bool fr_event_list_empty (fr_event_list_t *el)
 Return whether the event loop has any active events.
 
int fr_event_list_kq (fr_event_list_t *el)
 Return the kq associated with an event list.
 
uint64_t fr_event_list_num_fds (fr_event_list_t *el)
 Return the number of file descriptors is_registered with this event loop.
 
uint64_t fr_event_list_num_timers (fr_event_list_t *el)
 Return the number of timer events currently scheduled.
 
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.
 
fr_time_t fr_event_list_time (fr_event_list_t *el)
 Get the current server time according to the event list.
 
int fr_event_loop (fr_event_list_t *el)
 Run an event loop.
 
void fr_event_loop_exit (fr_event_list_t *el, int code)
 Signal an event loop exit with the specified code.
 
bool fr_event_loop_exiting (fr_event_list_t *el)
 Check to see whether the event loop is in the process of exiting.
 
int fr_event_post_delete (fr_event_list_t *el, fr_event_post_cb_t callback, void *uctx))
 Delete a post-event callback from the event list.
 
int fr_event_post_insert (fr_event_list_t *el, fr_event_post_cb_t callback, void *uctx))
 Add a post-event callback to the event list.
 
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.
 
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.
 
void fr_event_service (fr_event_list_t *el)
 Service any outstanding timer or file descriptor events.
 
int fr_event_user_delete (fr_event_list_t *el, fr_event_user_cb_t user, void *uctx))
 
int fr_event_user_trigger (fr_event_list_t *el, fr_event_user_t *ev)
 Trigger a user event.
 

Detailed Description

Wrapper around libkqueue to make managing events easier.

Timer lists with event callbacks.

Definition in file event.h.


Data Structure Documentation

◆ fr_event_funcs_t

union fr_event_funcs_t

Union of all filter functions.

Definition at line 214 of file event.h.

+ Collaboration diagram for fr_event_funcs_t:
Data Fields
fr_event_io_func_t io Read/write functions.
fr_event_vnode_func_t vnode vnode callback functions.

◆ fr_event_io_func_t

struct fr_event_io_func_t

Callbacks for the FR_EVENT_FILTER_IO filter.

Definition at line 189 of file event.h.

+ Collaboration diagram for fr_event_io_func_t:
Data Fields
fr_event_fd_cb_t read Callback for when data is available.
fr_event_fd_cb_t write Callback for when we can write data.

◆ fr_event_list_pub_s

struct fr_event_list_pub_s

Public event list structure.

Make the event timer list available, but nothing else.

This allows us to access these values without the cost of a function call.

Definition at line 46 of file event.h.

+ Collaboration diagram for fr_event_list_pub_s:
Data Fields
fr_timer_list_t * tl The timer list associated with this event loop.

◆ fr_event_update_t

struct fr_event_update_t

Structure describing a modification to a filter's state.

Definition at line 97 of file event.h.

Data Fields
size_t offset Offset of function in func struct.
fr_event_op_t op Operation to perform on function/filter.

◆ fr_event_vnode_func_t

struct fr_event_vnode_func_t

Callbacks for the FR_EVENT_FILTER_VNODE filter.

Definition at line 196 of file event.h.

+ Collaboration diagram for fr_event_vnode_func_t:
Data Fields
fr_event_fd_cb_t attrib File attributes changed.
fr_event_fd_cb_t delete The file was deleted.
fr_event_fd_cb_t extend Additional files were added to a directory.
fr_event_fd_cb_t link The link count on the file changed.
fr_event_fd_cb_t rename The file was renamed.
fr_event_fd_cb_t write The file was written to.

Macro Definition Documentation

◆ EVENT_DEBUG

#define EVENT_DEBUG (   ...)

Definition at line 66 of file event.h.

◆ fr_event_fd_insert

#define fr_event_fd_insert (   ...)    _fr_event_fd_insert(NDEBUG_LOCATION_EXP __VA_ARGS__)

Definition at line 248 of file event.h.

◆ fr_event_fd_mode

#define fr_event_fd_mode (   ...)    _fr_event_fd_move(NDEBUG_LOCATION_EXP __VA_ARGS__)

Definition at line 226 of file event.h.

◆ fr_event_filter_insert

#define fr_event_filter_insert (   ...)    _fr_event_filter_insert(NDEBUG_LOCATION_EXP __VA_ARGS__)

Definition at line 235 of file event.h.

◆ fr_event_filter_update

#define fr_event_filter_update (   ...)    _fr_event_filter_update(NDEBUG_LOCATION_EXP __VA_ARGS__)

Definition at line 240 of file event.h.

◆ fr_event_pid_reap

#define fr_event_pid_reap (   ...)    _fr_event_pid_reap(NDEBUG_LOCATION_EXP __VA_ARGS__)

Definition at line 273 of file event.h.

◆ fr_event_pid_wait

#define fr_event_pid_wait (   ...)    _fr_event_pid_wait(NDEBUG_LOCATION_EXP __VA_ARGS__)

Definition at line 267 of file event.h.

◆ FR_EVENT_RESUME

#define FR_EVENT_RESUME (   _s,
  _f 
)    { .offset = offsetof(_s, _f), .op = FR_EVENT_OP_RESUME }

Re-add the filter for a func from kevent.

Use to populate elements in an array of fr_event_update_t.

{ 0 }
}
#define FR_EVENT_RESUME(_s, _f)
Re-add the filter for a func from kevent.
Definition event.h:132
Callbacks for the FR_EVENT_FILTER_IO filter.
Definition event.h:189
Structure describing a modification to a filter's state.
Definition event.h:97
static fr_event_update_t resume_read[]
Definition master.c:175
Parameters
[in]_sthe structure containing the func to suspend.
[in]_fthe func to resume.

Definition at line 132 of file event.h.

◆ FR_EVENT_SUSPEND

#define FR_EVENT_SUSPEND (   _s,
  _f 
)    { .offset = offsetof(_s, _f), .op = FR_EVENT_OP_SUSPEND }

Temporarily remove the filter for a func from kevent.

Use to populate elements in an array of fr_event_update_t.

{ 0 }
}
#define FR_EVENT_SUSPEND(_s, _f)
Temporarily remove the filter for a func from kevent.
Definition event.h:116
static fr_event_update_t pause_read[]
Definition master.c:170
Parameters
[in]_sthe structure containing the func to suspend.
[in]_fthe func to suspend.

Definition at line 116 of file event.h.

◆ fr_event_user_insert

#define fr_event_user_insert (   _ctx,
  _ev_p,
  _el,
  _trigger,
  _callback,
  _uctx 
)     _fr_event_user_insert(NDEBUG_LOCATION_EXP _ctx, _ev_p, _el, _trigger, _callback, _uctx)

Definition at line 280 of file event.h.

Typedef Documentation

◆ fr_event_error_cb_t

typedef void(* fr_event_error_cb_t) (fr_event_list_t *el, int fd, int flags, int fd_errno, void *uctx)

Called when an IO error event occurs on a file descriptor.

Parameters
[in]elEvent list the file descriptor was inserted into.
[in]fdThat experienced the IO event.
[in]flagsfield as returned by kevent.
[in]fd_errnoFile descriptor error.
[in]uctxUser ctx passed to fr_event_fd_insert.

Definition at line 161 of file event.h.

◆ fr_event_fd_cb_t

typedef void(* fr_event_fd_cb_t) (fr_event_list_t *el, int fd, int flags, void *uctx)

Called when an IO event occurs on a file descriptor.

Parameters
[in]elEvent list the file descriptor was inserted into.
[in]fdThat experienced the IO event.
[in]flagsfield as returned by kevent.
[in]uctxUser ctx passed to fr_event_fd_insert.

Definition at line 151 of file event.h.

◆ fr_event_fd_t

typedef struct fr_event_fd fr_event_fd_t

An opaque file descriptor handle.

Definition at line 71 of file event.h.

◆ fr_event_list_t

Definition at line 37 of file event.h.

◆ fr_event_pid_cb_t

typedef void(* fr_event_pid_cb_t) (fr_event_list_t *el, pid_t pid, int status, void *uctx)

Called when a child process has exited.

Parameters
[in]elEvent list
[in]pidThat exited
[in]statusexit status
[in]uctxUser ctx passed to fr_event_fd_insert.

Definition at line 170 of file event.h.

◆ fr_event_pid_t

typedef struct fr_event_pid fr_event_pid_t

An opaque PID status handle.

Definition at line 75 of file event.h.

◆ fr_event_post_cb_t

typedef void(* fr_event_post_cb_t) (fr_event_list_t *el, fr_time_t now, void *uctx)

Called when a post event fires.

Parameters
[in]elEvent list the post event was inserted into.
[in]nowThe current time.
[in]uctxUser ctx passed to fr_timer_in or fr_timer_at.

Definition at line 185 of file event.h.

◆ fr_event_status_cb_t

typedef int(* fr_event_status_cb_t) (fr_time_t now, fr_time_delta_t wake, void *uctx)

Called after each event loop cycle.

Called before calling kqueue to put the thread in a sleeping state.

Parameters
[in]nowThe current time.
[in]wakeWhen we'll next need to wake up to service an event.
[in]uctxUser ctx passed to fr_event_list_alloc.

Definition at line 142 of file event.h.

◆ fr_event_user_cb_t

typedef void(* fr_event_user_cb_t) (fr_event_list_t *el, void *uctx)

Called when a user kevent occurs.

Parameters
[in]elEvent list
[in]uctxUser ctx passed to fr_event_user_insert.

Definition at line 177 of file event.h.

◆ fr_event_user_t

An opaque user event handle.

Definition at line 79 of file event.h.

Enumeration Type Documentation

◆ fr_event_filter_t

The type of filter to install for an FD.

Enumerator
FR_EVENT_FILTER_IO 

Combined filter for read/write functions/.

FR_EVENT_FILTER_VNODE 

Filter for vnode subfilters.

Definition at line 83 of file event.h.

◆ fr_event_op_t

Operations to perform on filter.

Enumerator
FR_EVENT_OP_SUSPEND 

Temporarily remove the relevant filter from kevent.

FR_EVENT_OP_RESUME 

Reinsert the filter into kevent.

Definition at line 90 of file event.h.

Function Documentation

◆ _fr_event_fd_insert()

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.

Parameters
[in]ctxto bind lifetime of the event to.
[out]ef_outWhere to store the output event
[in]elto insert fd callback into.
[in]fdto install filters for.
[in]read_fnfunction to call when fd is readable.
[in]write_fnfunction to call when fd is writable.
[in]errorfunction to call when an error occurs on the fd.
[in]uctxto pass to handler.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1179 of file event.c.

+ Here is the call graph for this function:

◆ _fr_event_fd_move()

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.

Note
Any pending events will not be transferred.
Parameters
[in]dstEvent list to move file descriptor event to.
[in]srcEvent list to move file descriptor from.
[in]fdof the event to move.
[in]filterof the event to move.
Returns
  • 0 on success.
  • -1 on failure. The event will remain active in the src list.

Definition at line 895 of file event.c.

+ Here is the call graph for this function:

◆ _fr_event_filter_insert()

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.

Parameters
[in]ctxto bind lifetime of the event to.
[out]ef_outPreviously allocated ef, or NULL.
[in]elto insert fd callback into.
[in]fdto install filters for.
[in]filterone of the fr_event_filter_t values.
[in]funcsStructure containing callback functions. If a function pointer is set, the equivalent kevent filter will be installed.
[in]errorfunction to call when an error occurs on the fd.
[in]uctxto pass to handler.

Definition at line 1023 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _fr_event_filter_update()

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:

{ 0 }
}
@ FR_EVENT_FILTER_IO
Combined filter for read/write functions/.
Definition event.h:84
#define fr_event_filter_update(...)
Definition event.h:240
static fr_event_list_t * el
Parameters
[in]elto update descriptor in.
[in]fdto update filters for.
[in]filterThe type of filter to update.
[in]updatesAn array of updates to toggle filters on/off without removing the callback function.

Definition at line 946 of file event.c.

+ Here is the call graph for this function:

◆ _fr_event_pid_reap()

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.

Parameters
[in]elto use to reap the process.
[in]pidto reap.
[in]callbackto call when the process is reaped. May be NULL.
[in]uctxto pass to callback.
Returns
  • -1 if we couldn't find the process or it has already exited/been reaped.
  • 0 on success (we setup a process handler).

Definition at line 1666 of file event.c.

+ Here is the call graph for this function:

◆ _fr_event_pid_wait()

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.

Note
The talloc parent of the memory returned in ev_p must not be changed. If the lifetime of the event needs to be bound to another context this function should be called with the existing event pointed to by ev_p.
Parameters
[in]ctxto bind lifetime of the event to.
[in]elto insert event into.
[in,out]ev_pIf 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]pidchild PID to wait for
[in]callbackfunction to execute if the event fires.
[in]uctxuser data to pass to the event.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1439 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _fr_event_user_insert()

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.

Parameters
[in]ctxto allocate the event in.
[in]elContaining the timer events.
[out]ev_pWhere to write a pointer.
[in]triggerWhether the user event is triggered initially.
[in]callbackfor EVFILT_USER.
[in]uctxfor the callback.
Returns
  • 0 on success.
  • -1 on error.

Definition at line 1885 of file event.c.

+ Here is the call graph for this function:

◆ fr_event_corral()

int fr_event_corral ( fr_event_list_t el,
fr_time_t  now,
bool  wait 
)

Gather outstanding timer and file descriptor events.

Parameters
[in]elto process events for.
[in]nowThe current time.
[in]waitif true, block on the kevent() call until a timer or file descriptor event occurs.
Returns
  • <0 error, or the event loop is exiting
  • the number of outstanding I/O events, +1 if at least one timer will fire.

Definition at line 2062 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_fd_armour()

int fr_event_fd_armour ( fr_event_list_t el,
int  fd,
fr_event_filter_t  filter,
uintptr_t  armour 
)

Armour an FD.

Parameters
[in]elto remove file descriptor from.
[in]fdto remove.
[in]filterThe type of filter to remove.
[in]armourThe armour to add.
Returns
  • 0 if file descriptor was armoured
  • <0 on error.

Definition at line 1288 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_fd_cb()

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.

Parameters
[in]efthe event filter fd handle.
[in]kq_filterIf the callbacks are indexed by filter.
[in]kq_fflagsIf the callbacks are indexed by NOTES (fflags).
Returns
  • NULL if no event it associated with the given ef/kq_filter or kq_fflags combo.
  • The callback that would be called if an event with this filter/fflag combo was received.

Definition at line 1264 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_fd_delete()

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.

Parameters
[in]elto remove file descriptor from.
[in]fdto remove.
[in]filterThe type of filter to remove.
Returns
  • 0 if file descriptor was removed.
  • <0 on error.

Definition at line 1206 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_fd_handle()

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.

Parameters
[in]elto search for fd/filter in.
[in]fdto search for.
[in]filterto search for.
Returns
  • NULL if no event could be found.
  • The opaque handle representing an fd event.

Definition at line 1242 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_fd_uctx()

void * fr_event_fd_uctx ( fr_event_fd_t ef)

Returns the uctx associated with an fr_event_fd_t handle.

Definition at line 1272 of file event.c.

+ Here is the caller graph for this function:

◆ fr_event_fd_unarmour()

int fr_event_fd_unarmour ( fr_event_list_t el,
int  fd,
fr_event_filter_t  filter,
uintptr_t  armour 
)

Unarmour an FD.

Parameters
[in]elto remove file descriptor from.
[in]fdto remove.
[in]filterThe type of filter to remove.
[in]armourThe armour to remove
Returns
  • 0 if file descriptor was unarmoured
  • <0 on error.

Definition at line 1318 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_list_alloc()

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.

Parameters
[in]ctxto allocate memory in.
[in]statuscallback, called on each iteration of the event list.
[in]status_uctxcontext for the status callback
Returns
  • A pointer to a new event list on success (free with talloc_free).
  • NULL on error.

Definition at line 2526 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_list_empty()

bool fr_event_list_empty ( fr_event_list_t el)

Return whether the event loop has any active events.

Definition at line 2590 of file event.c.

+ Here is the call graph for this function:

◆ fr_event_list_kq()

int fr_event_list_kq ( fr_event_list_t el)

Return the kq associated with an event list.

Parameters
[in]elto return timer events for.
Returns
kq

Definition at line 575 of file event.c.

◆ fr_event_list_num_fds()

uint64_t fr_event_list_num_fds ( fr_event_list_t el)

Return the number of file descriptors is_registered with this event loop.

Definition at line 551 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_list_num_timers()

uint64_t fr_event_list_num_timers ( fr_event_list_t el)

Return the number of timer events currently scheduled.

Parameters
[in]elto return timer events for.
Returns
number of timer events.

Definition at line 563 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_list_reap_signal()

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.

Parameters
[in]elcontaining the processes to reap.
[in]timeouthow long to wait before we signal the processes.
[in]signalto send to processes. Should be a fatal signal.
Returns
The number of processes reaped.

Definition at line 1702 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_list_time()

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.

Parameters
[in]elto get time from.
Returns
the current time according to the event list.

Definition at line 593 of file event.c.

+ Here is the caller graph for this function:

◆ fr_event_loop()

int fr_event_loop ( fr_event_list_t el)

Run an event loop.

Note
Will not return until fr_event_loop_exit is called.
Parameters
[in]elto start processing.

Definition at line 2397 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_loop_exit()

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.

Parameters
[in]elto signal to exit.
[in]codefor fr_event_loop to return.

Definition at line 2375 of file event.c.

+ Here is the caller graph for this function:

◆ fr_event_loop_exiting()

bool fr_event_loop_exiting ( fr_event_list_t el)

Check to see whether the event loop is in the process of exiting.

Parameters
[in]elto check.

Definition at line 2386 of file event.c.

+ Here is the caller graph for this function:

◆ fr_event_post_delete()

int fr_event_post_delete ( fr_event_list_t el,
fr_event_post_cb_t  callback,
void *  uctx 
)

Delete a post-event callback from the event list.

Parameters
[in]elContaining the timer events.
[in]callbackThe post-processing callback.
[in]uctxfor the callback.
Returns
  • < 0 on error
  • 0 on success

Definition at line 2033 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_post_insert()

int fr_event_post_insert ( fr_event_list_t el,
fr_event_post_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.

Parameters
[in]elContaining the timer events.
[in]callbackThe post-processing callback.
[in]uctxfor the callback.
Returns
  • < 0 on error
  • 0 on success

Definition at line 2011 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_pre_delete()

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.

Parameters
[in]elContaining the timer events.
[in]callbackThe pre-processing callback.
[in]uctxfor the callback.
Returns
  • < 0 on error
  • 0 on success

Definition at line 1979 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_pre_insert()

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.

Parameters
[in]elContaining the timer events.
[in]callbackThe pre-processing callback.
[in]uctxfor the callback.
Returns
  • < 0 on error
  • 0 on success

Definition at line 1957 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_service()

void fr_event_service ( fr_event_list_t el)

Service any outstanding timer or file descriptor events.

Parameters
[in]elcontaining events to service.

Definition at line 2197 of file event.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_event_user_delete()

int fr_event_user_delete ( fr_event_list_t el,
fr_event_user_cb_t  user,
void *  uctx 
)

◆ fr_event_user_trigger()

int fr_event_user_trigger ( fr_event_list_t el,
fr_event_user_t ev 
)

Trigger a user event.

Parameters
[in]elcontaining the user event.
[in]evHandle for the user event.
Returns
  • 0 on success.
  • -1 on error.

Definition at line 1931 of file event.c.

+ Here is the call graph for this function: