![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Various types of event timer list. More...
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/time.h>
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/timer.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/util/lst.h>
#include <freeradius-devel/util/rb.h>
#include <stdbool.h>
#include <talloc.h>
Go to the source code of this file.
Data Structures | |
struct | fr_timer_list_s |
An event timer list. More... | |
union | fr_timer_list_s.__unnamed154__ |
struct | fr_timer_s |
A timer event. More... | |
union | fr_timer_s.__unnamed156__ |
struct | timer_list_funcs_t |
Macros | |
#define | _TIMER_PRIVATE 1 |
#define | CHECK_PARENT(_ev) |
#define | EVENT_ARMED(_ev) ((_ev)->tl != NULL) |
Typedefs | |
typedef struct fr_timer_list_s | fr_timer_list_t |
typedef int(* | timer_disarm_t) (fr_timer_t *ev) |
Specialisation function to delete a timer. | |
typedef int(* | timer_insert_t) (fr_timer_list_t *tl, fr_timer_t *ev) |
Specialisation function to insert a timer. | |
typedef int(* | timer_list_deferred_t) (fr_timer_list_t *tl) |
Process any deferred timer events. | |
typedef fr_timer_t *(* | timer_list_head_t) (fr_timer_list_t *tl) |
Return the soonest timer event. | |
typedef uint64_t(* | timer_list_num_elements_t) (fr_timer_list_t *tl) |
Return the number of elements in the list. | |
typedef int(* | timer_list_run_t) (fr_timer_list_t *tl, fr_time_t *when) |
Specialisation function to execute any pending timers. | |
Enumerations | |
enum | timer_list_type_t { TIMER_LIST_TYPE_LST = 1 , TIMER_LIST_TYPE_ORDERED = 2 } |
What type of event list the timer is inserted into. More... | |
Functions | |
int | _fr_timer_at (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_timer_list_t *tl, fr_timer_t **ev_p, fr_time_t when, bool free_on_fire, fr_timer_cb_t callback, void const *uctx) |
Insert a timer event into an event list. | |
int | _fr_timer_in (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_timer_list_t *tl, fr_timer_t **ev_p, fr_time_delta_t delta, bool free_on_fire, fr_timer_cb_t callback, void const *uctx) |
Insert a timer event into an event list. | |
static void | _parent_timer_cb (UNUSED fr_timer_list_t *parent_tl, fr_time_t when, void *uctx) |
This callback fires in the parent to execute events in this sublist. | |
static int | _timer_free (fr_timer_t *ev) |
Remove an event from the event loop. | |
static int | _timer_list_free (fr_timer_list_t *tl) |
Cleanup all timers currently in the list. | |
bool | fr_timer_armed (fr_timer_t *ev) |
Check if a timer event is armed. | |
int | fr_timer_delete (fr_timer_t **ev_p) |
Delete a timer event and free its memory. | |
int | fr_timer_disarm (fr_timer_t *ev) |
Remove an event from the event list, but don't free the memory. | |
int | fr_timer_list_disarm (fr_timer_list_t *tl) |
Disable all timers in a list. | |
fr_timer_list_t * | fr_timer_list_lst_alloc (TALLOC_CTX *ctx, fr_timer_list_t *parent) |
Allocate a new lst based timer list. | |
uint64_t | fr_timer_list_num_events (fr_timer_list_t *tl) |
Return number of pending events. | |
fr_timer_list_t * | fr_timer_list_ordered_alloc (TALLOC_CTX *ctx, fr_timer_list_t *parent) |
Allocate a new sorted event timer list. | |
int | fr_timer_list_run (fr_timer_list_t *tl, fr_time_t *when) |
Execute any pending events in the event loop. | |
void | fr_timer_list_set_time_func (fr_timer_list_t *tl, fr_event_time_source_t func) |
Override event list time source. | |
fr_time_t | fr_timer_list_when (fr_timer_list_t *tl) |
Return the time of the next event. | |
fr_time_t | fr_timer_when (fr_timer_t *ev) |
Internal timestamp representing when the timer should fire. | |
static int8_t | timer_cmp (void const *a, void const *b) |
Compare two timer events to see which one should occur first. | |
static fr_timer_list_t * | timer_list_alloc (TALLOC_CTX *ctx, fr_timer_list_t *parent) |
static int | timer_list_lst_deferred (fr_timer_list_t *tl) |
Insert a timer event into a the lst. | |
static fr_timer_t * | timer_list_lst_head (fr_timer_list_t *tl) |
Return the head of the event list. | |
static uint64_t | timer_list_lst_num_events (fr_timer_list_t *tl) |
static int | timer_list_lst_run (fr_timer_list_t *tl, fr_time_t *when) |
Run all scheduled timer events in a lst. | |
static int | timer_list_ordered_deferred (fr_timer_list_t *tl) |
Move all deferred events into the ordered event list. | |
static fr_timer_t * | timer_list_ordered_head (fr_timer_list_t *tl) |
Return the head of the ordered list. | |
static uint64_t | timer_list_ordered_num_events (fr_timer_list_t *tl) |
static int | timer_list_ordered_run (fr_timer_list_t *tl, fr_time_t *when) |
Run all scheduled events in an ordered list. | |
static int | timer_list_parent_update (fr_timer_list_t *tl) |
Utility function to update parent timers. | |
static int | timer_lst_disarm (fr_timer_t *ev) |
static int | timer_lst_insert_at (fr_timer_list_t *tl, fr_timer_t *ev) |
Insert a timer event into a single event timer list. | |
static int | timer_ordered_disarm (fr_timer_t *ev) |
Remove a timer from a timer list, but don't free it. | |
static int | timer_ordered_insert_at (fr_timer_list_t *tl, fr_timer_t *ev) |
Insert an event into an ordered timer list. | |
Variables | |
static timer_list_funcs_t const | timer_funcs [] |
Functions for performing operations on various types of timer list. | |
Various types of event timer list.
Definition in file timer.c.
struct fr_timer_list_s |
Data Fields | ||
---|---|---|
union fr_timer_list_s.__unnamed154__ | __unnamed__ | |
timer_head_t | deferred |
A list of timer events to be inserted, after the current batch has been processed. This prevents "busy" timer loops, where other events may starve, or we may never exit. |
bool | in_handler | Whether we're currently in a callback. |
fr_timer_list_t * | parent | Parent list to insert event into (if any). |
fr_timer_t * | parent_ev | Event in the parent's event loop. |
struct fr_timer_list_pub_s | pub | Public interface to the event timer list. |
timer_list_type_t | type |
union fr_timer_list_s.__unnamed154__ |
struct fr_timer_s |
Data Fields | ||
---|---|---|
union fr_timer_s.__unnamed156__ | __unnamed__ | |
fr_timer_cb_t | callback | Callback to execute when the timer fires. |
fr_timer_entry_t | entry | Entry in a list of timer events. |
char const * | file | Source file this event was last updated in. |
bool | free_on_fire | Whether to free the event when it fires. |
int | line | Line this event was last updated on. |
TALLOC_CTX * | linked_ctx | talloc ctx this event was bound to. |
fr_timer_t ** | parent | A pointer to the parent structure containing the timer event. |
fr_timer_list_t * | tl |
The event list this timer is part of. This is set to NULL when an event is disarmed, but all other fields are left intact. |
void const * | uctx | Context pointer to pass to the callback. |
fr_time_t | when | When this timer should fire. |
union fr_timer_s.__unnamed156__ |
Data Fields | ||
---|---|---|
fr_lst_index_t | lst_idx | Where to store opaque lst data, not used for ordered lists. |
fr_dlist_t | ordered_entry | Entry in an ordered list of timer events. |
struct timer_list_funcs_t |
Data Fields | ||
---|---|---|
timer_list_deferred_t | deferred | Function to process deferred events. |
timer_disarm_t | disarm | Function to delete a timer event. |
timer_list_head_t | head | Function to get the head of the list. |
timer_insert_t | insert | Function to insert a timer event. |
timer_list_num_elements_t | num_events | Function to get the number of elements in the list. |
timer_list_run_t | run | Function to run a timer event. |
#define CHECK_PARENT | ( | _ev | ) |
typedef struct fr_timer_list_s fr_timer_list_t |
typedef int(* timer_disarm_t) (fr_timer_t *ev) |
typedef int(* timer_insert_t) (fr_timer_list_t *tl, fr_timer_t *ev) |
typedef int(* timer_list_deferred_t) (fr_timer_list_t *tl) |
typedef fr_timer_t *(* timer_list_head_t) (fr_timer_list_t *tl) |
typedef uint64_t(* timer_list_num_elements_t) (fr_timer_list_t *tl) |
typedef int(* timer_list_run_t) (fr_timer_list_t *tl, fr_time_t *when) |
Specialisation function to execute any pending timers.
[in] | tl | Timer list to execute. |
[in,out] | when | Our current time, updated to the next event time (i.e. the next time we'll need to run something) |
enum timer_list_type_t |
int _fr_timer_at | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_timer_list_t * | tl, | ||
fr_timer_t ** | ev_p, | ||
fr_time_t | when, | ||
bool | free_on_fire, | ||
fr_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] | tl | 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] | free_on_fire | Whether event memory should be freed if the event fires. |
[in] | callback | function to execute if the event fires. |
[in] | uctx | user data to pass to the event. |
Definition at line 375 of file timer.c.
int _fr_timer_in | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_timer_list_t * | tl, | ||
fr_timer_t ** | ev_p, | ||
fr_time_delta_t | delta, | ||
bool | free_on_fire, | ||
fr_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] | tl | 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 534 of file timer.c.
|
static |
This callback fires in the parent to execute events in this sublist.
[in] | parent_tl | Parent event timer list. |
[in] | when | When the parent timer fired. |
[in] | uctx | Sublist to execute. |
Definition at line 244 of file timer.c.
|
static |
|
static |
bool fr_timer_armed | ( | fr_timer_t * | ev | ) |
int fr_timer_delete | ( | fr_timer_t ** | ev_p | ) |
int fr_timer_disarm | ( | fr_timer_t * | ev | ) |
int fr_timer_list_disarm | ( | fr_timer_list_t * | tl | ) |
fr_timer_list_t * fr_timer_list_lst_alloc | ( | TALLOC_CTX * | ctx, |
fr_timer_list_t * | parent | ||
) |
uint64_t fr_timer_list_num_events | ( | fr_timer_list_t * | tl | ) |
fr_timer_list_t * fr_timer_list_ordered_alloc | ( | TALLOC_CTX * | ctx, |
fr_timer_list_t * | parent | ||
) |
int fr_timer_list_run | ( | fr_timer_list_t * | tl, |
fr_time_t * | when | ||
) |
Execute any pending events in the event loop.
[in] | tl | to execute events in. |
[in] | when | Process events scheduled to run before or at this time.
|
Definition at line 815 of file timer.c.
void fr_timer_list_set_time_func | ( | fr_timer_list_t * | tl, |
fr_event_time_source_t | func | ||
) |
fr_time_t fr_timer_list_when | ( | fr_timer_list_t * | tl | ) |
fr_time_t fr_timer_when | ( | fr_timer_t * | ev | ) |
|
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 231 of file timer.c.
|
static |
|
static |
|
static |
|
static |
|
static |
Run all scheduled timer events in a lst.
[in] | tl | containing the timer events. |
[in] | when | Process events scheduled to run before or at this time.
|
Definition at line 698 of file timer.c.
|
static |
|
static |
|
static |
|
static |
Run all scheduled events in an ordered list.
[in] | tl | containing the timer events. |
[in] | when | Process events scheduled to run before or at this time.
|
Definition at line 757 of file timer.c.
|
inlinestatic |
|
static |
|
static |
|
static |
|
static |
|
static |
Functions for performing operations on various types of timer list.