25 RCSIDH(connection_h,
"$Id: 524f5d1ca431424c85351c91d0ea390f4a54e23f $")
31 #include <freeradius-devel/util/event.h>
32 #include <freeradius-devel/util/table.h>
33 #include <freeradius-devel/util/talloc.h>
36 # error _CONST can only be defined in the local header
38 #ifndef _CONNECTION_PRIVATE
270 char const *log_prefix,
void const *
uctx);
void connection_signal_shutdown(connection_t *conn)
Shuts down a connection gracefully.
void(* connection_watch_t)(connection_t *conn, connection_state_t prev, connection_state_t state, void *uctx)
Receive a notification when a connection enters a particular state.
void connection_watch_enable(connection_watch_entry_t *entry)
Enable a watcher.
connection_state_t(* connection_failed_t)(void *h, connection_state_t state, void *uctx)
Notification that a connection attempt has failed.
uint64_t connection_get_num_timed_out(connection_t const *conn)
Return the number of times this connection has timed out whilst connecting.
uint64_t _CONST timed_out
How many times has this connection timed out when connecting.
void connection_watch_disable(connection_watch_entry_t *entry)
Disable a watcher.
void(* connection_close_t)(fr_event_list_t *el, void *h, void *uctx)
Notification that the connection has errored and must be closed.
int connection_del_watch_post(connection_t *conn, connection_state_t state, connection_watch_t watch)
Remove a watch function from a post list.
fr_event_list_t *_CONST el
Event list for timers and I/O events.
connection_state_t(* connection_init_t)(void **h_out, connection_t *conn, void *uctx)
Callback for the initialise state.
bool connection_watch_is_enabled(connection_watch_entry_t *entry)
Return the state of a watch entry.
void connection_signal_halt(connection_t *conn)
Shuts down a connection ungracefully.
@ CONNECTION_STATE_FAILED
Connection has failed.
@ CONNECTION_STATE_HALTED
The connection is in a halted stat.
@ CONNECTION_STATE_CLOSED
Connection has been closed.
@ CONNECTION_STATE_CONNECTED
File descriptor is open (ready for writing).
@ CONNECTION_STATE_TIMEOUT
Timeout during CONNECTION_STATE_CONNECTING.
@ CONNECTION_STATE_INIT
Init state, sets up connection.
@ CONNECTION_STATE_CONNECTING
Waiting for connection to establish.
@ CONNECTION_STATE_SHUTDOWN
Connection is shutting down.
void connection_signals_resume(connection_t *conn)
Resume processing of deferred signals.
uint64_t connection_get_num_reconnected(connection_t const *conn)
Return the number of times we've attempted to establish or re-establish this connection.
uint64_t _CONST reconnected
How many times we've attempted to establish or re-establish this connection.
void *_CONST h
Connection handle.
bool _CONST triggers
do we run the triggers?
@ CONNECTION_EXPIRED
Connection is being reconnected because it's at the end of its life.
@ CONNECTION_FAILED
Connection is being reconnected because it failed.
connection_state_t(* connection_open_t)(fr_event_list_t *el, void *h, void *uctx)
Notification that the connection is now open.
void connection_watch_set_uctx(connection_watch_entry_t *entry, void const *uctx)
Change the uctx of an entry.
connection_state_t _CONST state
Current connection state.
void connection_signal_reconnect(connection_t *conn, connection_reason_t reason)
Asynchronously signal the connection should be reconnected.
connection_watch_entry_t * connection_add_watch_pre(connection_t *conn, connection_state_t state, connection_watch_t watch, bool oneshot, void const *uctx)
Add a callback to be executed before a state function has been called.
char const *_CONST name
Prefix to add to log messages.
connection_state_t _CONST prev
The previous state the connection was in.
fr_table_num_ordered_t const connection_states[]
int connection_signal_on_fd(connection_t *conn, int fd)
Setup the connection to change states to connected or failed based on I/O events.
void connection_signal_init(connection_t *conn)
Asynchronously signal a halted connection to start.
connection_watch_entry_t * connection_add_watch_post(connection_t *conn, connection_state_t state, connection_watch_t watch, bool oneshot, void const *uctx)
Add a callback to be executed after a state function has been called.
connection_shutdown_t shutdown
connection_failed_t failed
size_t connection_states_len
connection_t * connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, connection_funcs_t const *funcs, connection_conf_t const *conf, char const *log_prefix, void const *uctx)
Allocate a new connection.
int connection_del_watch_pre(connection_t *conn, connection_state_t state, connection_watch_t watch)
Remove a watch function from a pre list.
fr_time_delta_t reconnection_delay
How long to wait after failures.
void connection_watch_enable_set_uctx(connection_watch_entry_t *entry, void const *uctx)
Enable a watcher and replace the uctx.
void connection_signal_connected(connection_t *conn)
Asynchronously signal that the connection is open.
void connection_signals_pause(connection_t *conn)
Pause processing of deferred signals.
fr_time_delta_t connection_timeout
How long to wait for the connection to open or for shutdown to close the connection.
uint64_t _CONST id
Unique identifier for the connection.
connection_state_t(* connection_shutdown_t)(fr_event_list_t *el, void *h, void *uctx)
Start the process of gracefully shutting down the connection.
Holds a complete set of functions for a connection.
Public fields for the connection.
fr_dcursor_eval_t void const * uctx
Stores all information relating to an event list.
An entry in a watch function list.
An element in an arbitrarily ordered array of name to num mappings.
A time delta, a difference in time measured in nanoseconds.
static fr_event_list_t * el