The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
A management API for bonding multiple connections together. More...
#include <freeradius-devel/server/trunk.h>
#include <freeradius-devel/server/connection.h>
#include <freeradius-devel/server/trigger.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/minmax_heap.h>
#include <freeradius-devel/util/stdatomic.h>
Go to the source code of this file.
Data Structures | |
struct | trunk_connection_s |
Associates request queues with a connection. More... | |
struct | trunk_request_s |
Wraps a normal request. More... | |
struct | trunk_request_state_log_t |
Trace state machine changes for a particular request. More... | |
struct | trunk_s |
Main trunk management handle. More... | |
struct | trunk_watch_entry_s |
An entry in a trunk watch function list. More... | |
Macros | |
#define | _TRUNK_PRIVATE 1 |
#define | CALL_WATCHERS(_trunk, _state) |
Call the state change watch functions. More... | |
#define | CONN_BAD_STATE_TRANSITION(_new) |
#define | CONN_REORDER(_tconn) |
Reorder the connections in the active heap. More... | |
#define | CONN_STATE_TRANSITION(_new, _log) |
#define | CONN_TRIGGER(_state) |
#define | COUNT_BY_STATE(_state, _list) |
#define | DEQUEUE_ALL(_src_list, _state) |
#define | DO_CONNECTION_ALLOC(_tconn) |
Allocate a new connection. More... | |
#define | DO_CONNECTION_NOTIFY(_tconn, _events) |
Change what events the connection should be notified about. More... | |
#define | DO_REQUEST_CANCEL(_treq, _reason) |
Call the cancel callback if set. More... | |
#define | DO_REQUEST_CANCEL_MUX(_tconn) |
Write one or more cancellation requests to a connection. More... | |
#define | DO_REQUEST_COMPLETE(_treq) |
Call the complete callback (if set) More... | |
#define | DO_REQUEST_CONN_RELEASE(_treq) |
Call the "conn_release" callback (if set) More... | |
#define | DO_REQUEST_DEMUX(_tconn) |
Read one or more requests from a connection. More... | |
#define | DO_REQUEST_FAIL(_treq, _prev_state) |
Call the fail callback (if set) More... | |
#define | DO_REQUEST_FREE(_treq) |
Call the free callback (if set) More... | |
#define | DO_REQUEST_MUX(_tconn) |
Write one or more requests to a connection. More... | |
#define | IN_HANDLER(_trunk) (((_trunk)->in_handler) != NULL) |
#define | IN_REQUEST_CANCEL_MUX(_trunk) (((_trunk)->funcs.request_cancel_mux) && ((_trunk)->in_handler == (void *)(_trunk)->funcs.request_cancel_mux)) |
#define | IN_REQUEST_DEMUX(_trunk) (((_trunk)->funcs.request_demux) && ((_trunk)->in_handler == (void *)(_trunk)->funcs.request_demux)) |
#define | IN_REQUEST_MUX(_trunk) (((_trunk)->funcs.request_mux) && ((_trunk)->in_handler == (void *)(_trunk)->funcs.request_mux)) |
#define | IO_FUNC_VERIFY(_func) fr_fatal_assert_msg(trunk->funcs._func, "CONSISTENCY_CHECK_FAILED %s[%i}: " #_func " was NULL", file, line) |
#define | IS_PROCESSING(_tconn) ((tconn)->pub.state & TRUNK_CONN_PROCESSING) |
#define | IS_SERVICEABLE(_tconn) ((_tconn)->pub.state & TRUNK_CONN_SERVICEABLE) |
#define | LOG_PREFIX trunk->log_prefix |
#define | OVER_MAX_CHECK if (++count > max) return (count - 1) |
#define | RECONNECT_BY_STATE(_state, _list) |
#define | REQUEST_BAD_STATE_TRANSITION(_new) |
#define | REQUEST_EXTRACT_BACKLOG(_treq) |
Remove the current request from the backlog. More... | |
#define | REQUEST_EXTRACT_CANCEL(_treq) fr_dlist_remove(&tconn->cancel, treq) |
Remove the current request from the cancel list. More... | |
#define | REQUEST_EXTRACT_CANCEL_PARTIAL(_treq) |
Remove the current request from the cancel_partial slot. More... | |
#define | REQUEST_EXTRACT_CANCEL_SENT(_treq) fr_dlist_remove(&tconn->cancel_sent, treq) |
Remove the current request from the cancel sent list. More... | |
#define | REQUEST_EXTRACT_PARTIAL(_treq) |
Remove the current request from the partial slot. More... | |
#define | REQUEST_EXTRACT_PENDING(_treq) |
Remove the current request from the pending list. More... | |
#define | REQUEST_EXTRACT_REAPABLE(_treq) fr_dlist_remove(&tconn->reapable, treq) |
Remove the current request from the reapable list. More... | |
#define | REQUEST_EXTRACT_SENT(_treq) fr_dlist_remove(&tconn->sent, treq) |
Remove the current request from the sent list. More... | |
#define | REQUEST_STATE_TRANSITION(_new) |
Record a request state transition and log appropriate output. More... | |
#define | REQUEST_TRIGGER(_state) |
#define | TCONN_DLIST_SEARCH(_dlist) |
#define | TCONN_DLIST_VERIFY(_dlist, _state) |
#define | TCONN_MINMAX_HEAP_SEARCH(_heap) |
#define | TCONN_MINMAX_HEAP_VERIFY(_heap, _state) |
#define | TCONN_TREQ_CHECKS(_treq, _state) |
#define | TREQ_DLIST_SEARCH(_dlist) |
#define | TREQ_DLIST_VERIFY(_dlist, _state) |
#define | TREQ_HEAP_SEARCH(_heap) |
#define | TREQ_HEAP_VERIFY(_heap, _state) |
#define | TREQ_OPTION_SEARCH(_option) |
#define | TREQ_OPTION_VERIFY(_option, _state) |
#define | TRUNK_REQUEST_STATE_LOG_MAX 20 |
The maximum number of state logs to record per request. More... | |
#define | TRUNK_STATE_TRANSITION(_new) |
#define | TRUNK_TCONN_CHECKS(_tconn, _state) |
Typedefs | |
typedef struct trunk_connection_s | trunk_connection_t |
typedef struct trunk_request_s | trunk_request_t |
typedef struct trunk_s | trunk_t |
typedef struct trunk_watch_entry_s | trunk_watch_entry_t |
An entry in a trunk watch function list. More... | |
Functions | |
static int | _state_log_entry_free (trunk_request_state_log_t *slog) |
Used for sanity checks to ensure all log entries have been freed. More... | |
static int | _trunk_connection_free (trunk_connection_t *tconn) |
Free a connection. More... | |
static void | _trunk_connection_lifetime_expire (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Trigger a reconnection of the trunk connection. More... | |
static void | _trunk_connection_on_closed (UNUSED connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Connection failed after it was connected. More... | |
static void | _trunk_connection_on_connected (UNUSED connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Connection transitioned to the connected state. More... | |
static void | _trunk_connection_on_connecting (UNUSED connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Connection transitioned to the connecting state. More... | |
static void | _trunk_connection_on_failed (connection_t *conn, connection_state_t prev, connection_state_t state, void *uctx) |
Connection failed. More... | |
static void | _trunk_connection_on_halted (UNUSED connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Connection transitioned to the halted state. More... | |
static void | _trunk_connection_on_init (UNUSED connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Connection transitioned to the the init state. More... | |
static void | _trunk_connection_on_shutdown (UNUSED connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Connection transitioned to the shutdown state. More... | |
static int8_t | _trunk_connection_order_by_shortest_queue (void const *one, void const *two) |
Order connections by queue depth. More... | |
static int | _trunk_free (trunk_t *trunk) |
Free a trunk, gracefully closing all connections. More... | |
static int | _trunk_request_free (trunk_request_t *treq) |
Actually free the trunk request. More... | |
static int8_t | _trunk_request_prioritise (void const *a, void const *b) |
Compare two protocol requests. More... | |
static void | _trunk_timer (fr_event_list_t *el, fr_time_t now, void *uctx) |
Event to periodically call the connection management function. More... | |
trunk_watch_entry_t * | trunk_add_watch (trunk_t *trunk, trunk_state_t state, trunk_watch_t watch, bool oneshot, void const *uctx) |
Add a watch entry to the trunk state list. More... | |
trunk_t * | trunk_alloc (TALLOC_CTX *ctx, fr_event_list_t *el, trunk_io_funcs_t const *funcs, trunk_conf_t const *conf, char const *log_prefix, void const *uctx, bool delay_start) |
Allocate a new collection of connections. More... | |
static void | trunk_backlog_drain (trunk_t *trunk) |
Drain the backlog of as many requests as possible. More... | |
static void | trunk_connection_auto_full (trunk_connection_t *tconn) |
Automatically mark a connection as inactive. More... | |
static void | trunk_connection_auto_unfull (trunk_connection_t *tconn) |
Automatically mark a connection as active or reconnect it. More... | |
void | trunk_connection_callback_readable (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx) |
Standard I/O read function. More... | |
void | trunk_connection_callback_writable (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx) |
Standard I/O write function. More... | |
static void | trunk_connection_close_if_empty (trunk_t *trunk, fr_dlist_head_t *head) |
Close connections in a particular connection list if they have no requests associated with them. More... | |
uint16_t | trunk_connection_count_by_state (trunk_t *trunk, int conn_state) |
Return the count number of connections in the specified states. More... | |
static void | trunk_connection_enter_active (trunk_connection_t *tconn) |
Transition a connection back to the active state. More... | |
static void | trunk_connection_enter_draining (trunk_connection_t *tconn) |
Transition a connection to the draining state. More... | |
static void | trunk_connection_enter_draining_to_free (trunk_connection_t *tconn) |
Transition a connection to the draining-to-reconnect state. More... | |
static void | trunk_connection_enter_full (trunk_connection_t *tconn) |
Transition a connection to the full state. More... | |
static void | trunk_connection_enter_inactive (trunk_connection_t *tconn) |
Transition a connection to the inactive state. More... | |
static void | trunk_connection_enter_inactive_draining (trunk_connection_t *tconn) |
Transition a connection to the inactive-draining state. More... | |
static void | trunk_connection_event_update (trunk_connection_t *tconn) |
Update the registrations for I/O events we're interested in. More... | |
bool | trunk_connection_in_state (trunk_connection_t *tconn, int state) |
Returns true if the trunk connection is in one of the specified states. More... | |
static bool | trunk_connection_is_full (trunk_connection_t *tconn) |
Return whether a trunk connection should currently be considered full. More... | |
int | trunk_connection_manage_schedule (trunk_t *trunk) |
Schedule a trunk management event for the next time the event loop is executed. More... | |
void | trunk_connection_manage_start (trunk_t *trunk) |
Allow the trunk to open and close connections in response to load. More... | |
void | trunk_connection_manage_stop (trunk_t *trunk) |
Stop the trunk from opening and closing connections in response to load. More... | |
int | trunk_connection_pop_cancellation (trunk_request_t **treq_out, trunk_connection_t *tconn) |
Pop a cancellation request off a connection's cancellation queue. More... | |
int | trunk_connection_pop_request (trunk_request_t **treq_out, trunk_connection_t *tconn) |
Pop a request off a connection's pending queue. More... | |
static void | trunk_connection_readable (trunk_connection_t *tconn) |
A connection is readable. More... | |
static void | trunk_connection_remove (trunk_connection_t *tconn) |
Remove a trunk connection from whichever list it's currently in. More... | |
static uint64_t | trunk_connection_requests_dequeue (fr_dlist_head_t *out, trunk_connection_t *tconn, int states, uint64_t max) |
Shift requests in the specified states onto new connections. More... | |
uint64_t | trunk_connection_requests_requeue (trunk_connection_t *tconn, int states, uint64_t max, bool fail_bound) |
Move requests off of a connection and requeue elsewhere. More... | |
static uint64_t | trunk_connection_requests_requeue_priv (trunk_connection_t *tconn, int states, uint64_t max, bool fail_bound) |
Remove requests in specified states from a connection, attempting to distribute them to new connections. More... | |
bool | trunk_connection_search (trunk_connection_t *tconn, void *ptr) |
void | trunk_connection_signal_active (trunk_connection_t *tconn) |
Signal a trunk connection is no longer full. More... | |
void | trunk_connection_signal_inactive (trunk_connection_t *tconn) |
Signal a trunk connection cannot accept more requests. More... | |
void | trunk_connection_signal_readable (trunk_connection_t *tconn) |
Signal that a trunk connection is readable. More... | |
void | trunk_connection_signal_reconnect (trunk_connection_t *tconn, connection_reason_t reason) |
Signal a trunk connection is no longer viable. More... | |
void | trunk_connection_signal_writable (trunk_connection_t *tconn) |
Signal that a trunk connection is writable. More... | |
static int | trunk_connection_spawn (trunk_t *trunk, fr_time_t now) |
Attempt to spawn a new connection. More... | |
void | trunk_connection_verify (char const *file, int line, trunk_connection_t *tconn) |
static void | trunk_connection_writable (trunk_connection_t *tconn) |
A connection is writable. More... | |
int | trunk_del_watch (trunk_t *trunk, trunk_state_t state, trunk_watch_t watch) |
Remove a watch function from a trunk state list. More... | |
static void | trunk_manage (trunk_t *trunk, fr_time_t now) |
Implements the algorithm we use to manage requests per connection levels. More... | |
static void | trunk_rebalance (trunk_t *trunk) |
Rebalance connections across active trunk members when a new connection becomes active. More... | |
void | trunk_reconnect (trunk_t *trunk, int states, connection_reason_t reason) |
Force the trunk to re-establish its connections. More... | |
trunk_request_t * | trunk_request_alloc (trunk_t *trunk, request_t *request) |
(Pre-)Allocate a new trunk request More... | |
static trunk_enqueue_t | trunk_request_check_enqueue (trunk_connection_t **tconn_out, trunk_t *trunk, request_t *request) |
Check to see if a trunk request can be enqueued. More... | |
uint32_t | trunk_request_count_by_connection (trunk_connection_t const *tconn, int req_state) |
Return the count number of requests associated with a trunk connection. More... | |
uint64_t | trunk_request_count_by_state (trunk_t *trunk, int conn_state, int req_state) |
Return a count of requests on a connection in a specific state. More... | |
trunk_enqueue_t | trunk_request_enqueue (trunk_request_t **treq_out, trunk_t *trunk, request_t *request, void *preq, void *rctx) |
Enqueue a request that needs data written to the trunk. More... | |
static trunk_enqueue_t | trunk_request_enqueue_existing (trunk_request_t *treq) |
Enqueue a request which has never been assigned to a connection or was previously cancelled. More... | |
trunk_enqueue_t | trunk_request_enqueue_on_conn (trunk_request_t **treq_out, trunk_connection_t *tconn, request_t *request, void *preq, void *rctx, bool ignore_limits) |
Enqueue additional requests on a specific connection. More... | |
static void | trunk_request_enter_backlog (trunk_request_t *treq, bool new) |
Transition a request to the backlog state, adding it to the backlog of the trunk. More... | |
static void | trunk_request_enter_cancel (trunk_request_t *treq, trunk_cancel_reason_t reason) |
Transition a request to the cancel state, placing it in a connection's cancellation list. More... | |
static void | trunk_request_enter_cancel_complete (trunk_request_t *treq) |
Cancellation was acked, the request is complete, free it. More... | |
static void | trunk_request_enter_cancel_partial (trunk_request_t *treq) |
Transition a request to the cancel_partial state, placing it in a connection's cancel_partial slot. More... | |
static void | trunk_request_enter_cancel_sent (trunk_request_t *treq) |
Transition a request to the cancel_sent state, placing it in a connection's cancel_sent list. More... | |
static void | trunk_request_enter_complete (trunk_request_t *treq) |
Request completed successfully, inform the API client and free the request. More... | |
static void | trunk_request_enter_failed (trunk_request_t *treq) |
Request failed, inform the API client and free the request. More... | |
static void | trunk_request_enter_partial (trunk_request_t *treq) |
Transition a request to the partial state, indicating that is has been partially sent. More... | |
static void | trunk_request_enter_pending (trunk_request_t *treq, trunk_connection_t *tconn, bool new) |
Transition a request to the pending state, adding it to the backlog of an active connection. More... | |
static void | trunk_request_enter_reapable (trunk_request_t *treq) |
Transition a request to the reapable state, indicating that it's been sent in its entirety, but no response is expected. More... | |
static void | trunk_request_enter_sent (trunk_request_t *treq) |
Transition a request to the sent state, indicating that it's been sent in its entirety. More... | |
static void | trunk_request_enter_unassigned (trunk_request_t *treq) |
Transition a request to the unassigned state, in preparation for re-assignment. More... | |
void | trunk_request_free (trunk_request_t **treq_to_free) |
If the trunk request is freed then update the target requests. More... | |
static void | trunk_request_remove_from_conn (trunk_request_t *treq) |
Remove a request from all connection lists. More... | |
trunk_enqueue_t | trunk_request_requeue (trunk_request_t *treq) |
Re-enqueue a request on the same connection. More... | |
bool | trunk_request_search (trunk_request_t *treq, void *ptr) |
void | trunk_request_signal_cancel (trunk_request_t *treq) |
Cancel a trunk request. More... | |
void | trunk_request_signal_cancel_complete (trunk_request_t *treq) |
Signal that a remote server acked our cancellation. More... | |
void | trunk_request_signal_cancel_partial (trunk_request_t *treq) |
Signal a partial cancel write. More... | |
void | trunk_request_signal_cancel_sent (trunk_request_t *treq) |
Signal that a remote server has been notified of the cancellation. More... | |
void | trunk_request_signal_complete (trunk_request_t *treq) |
Signal that a trunk request is complete. More... | |
void | trunk_request_signal_fail (trunk_request_t *treq) |
Signal that a trunk request failed. More... | |
void | trunk_request_signal_partial (trunk_request_t *treq) |
Signal a partial write. More... | |
void | trunk_request_signal_reapable (trunk_request_t *treq) |
Signal that the request was written to a connection successfully, but no response is expected. More... | |
void | trunk_request_signal_sent (trunk_request_t *treq) |
Signal that the request was written to a connection successfully. More... | |
void | trunk_request_state_log (fr_log_t const *log, fr_log_type_t log_type, char const *file, int line, trunk_request_t const *treq) |
void | trunk_request_state_log_entry_add (char const *function, int line, trunk_request_t *treq, trunk_request_state_t new) |
void | trunk_request_verify (char const *file, int line, trunk_request_t *treq) |
static uint64_t | trunk_requests_per_connection (uint16_t *conn_count_out, uint32_t *req_count_out, trunk_t *trunk, fr_time_t now, NDEBUG_UNUSED bool verify) |
Update timestamps for when we last had a transition from above target to below target or vice versa. More... | |
bool | trunk_search (trunk_t *trunk, void *ptr) |
int | trunk_start (trunk_t *trunk) |
Start the trunk running. More... | |
void | trunk_verify (char const *file, int line, trunk_t *trunk) |
Verify a trunk. More... | |
static void | trunk_watch_call (trunk_t *trunk, fr_dlist_head_t *list, trunk_state_t state) |
Call a list of watch functions associated with a state. More... | |
A management API for bonding multiple connections together.
Definition in file trunk.c.
struct trunk_connection_s |
Data Fields | ||
---|---|---|
fr_dlist_head_t | cancel | Requests in the cancel state. |
trunk_request_t * | cancel_partial | Partially written cancellation request. |
fr_dlist_head_t | cancel_sent | Sent cancellation request. |
fr_dlist_t | entry | Used to track the connection in the connecting, full and failed lists. |
trunk_connection_event_t | events | The current events we expect to be notified on. |
fr_heap_index_t | heap_id | Used to track the connection in the connected heap. |
fr_event_timer_t const * | lifetime_ev | Maximum time this connection can be open. |
trunk_request_t * | partial | Partially written request. |
fr_heap_t * | pending | Requests waiting to be sent. |
struct trunk_connection_pub_s | pub |
Public fields in the trunk connection. This MUST be the first field in this structure. |
fr_dlist_head_t | reapable | Idle request. |
fr_dlist_head_t | sent | Sent request. |
uint64_t | sent_count | The number of requests that have been sent using this connection. |
struct trunk_request_s |
Data Fields | ||
---|---|---|
bool | bound_to_conn | Fail the request if there's an attempt to re-enqueue it. |
trunk_cancel_reason_t | cancel_reason | Why this request was cancelled. |
fr_dlist_t | entry | Used to track the trunk request in the conn->sent or trunk->backlog request. |
fr_heap_index_t | heap_id | Used to track the request conn->pending heap. |
uint64_t | id | Trunk request ID. |
fr_time_t | last_freed | Last time this request was freed. |
fr_dlist_head_t | log | State change log. |
struct trunk_request_pub_s | pub |
Public fields in the trunk request. This MUST be the first field in this structure. |
bool | sent |
Trunk request has been sent at least once. Used so that re-queueing doesn't increase trunk |
struct trunk_request_state_log_t |
Data Fields | ||
---|---|---|
fr_dlist_t | entry | Entry in the linked list. |
trunk_request_state_t | from | What state we transitioned from. |
char const * | function | State change occurred in. |
int | line | Line change occurred on. |
fr_dlist_head_t * | log_head | To allow the log entry to remove itself on free. |
trunk_connection_t * | tconn |
The request was associated with. Pointer may now be invalid, do no de-reference. |
uint64_t | tconn_id | If the treq was associated with a connection the connection ID. |
trunk_connection_state_t | tconn_state | If the treq was associated with a connection the connection state at the time of the state transition. |
trunk_request_state_t | to | What state we transitioned to. |
struct trunk_s |
Data Fields | ||
---|---|---|
fr_minmax_heap_t * | active | Connections which can service requests. |
fr_heap_t * | backlog |
The request backlog. Requests we couldn't immediately assign to a connection. |
fr_dlist_head_t | closed |
Connections that have closed. Either due to shutdown, reconnection or failure. |
trunk_conf_t | conf | Trunk common configuration. |
fr_dlist_head_t | connecting | Connections which are not yet in the open state. |
fr_dlist_head_t | draining | Connections that will be freed once all their requests are complete, but can be reactivated. |
fr_dlist_head_t | draining_to_free | Connections that will be freed once all their requests are complete. |
fr_event_list_t * | el | Event list used by this trunk and the connection. |
fr_dlist_head_t | failed | Connections that'll be reconnected shortly. |
fr_dlist_head_t | free_requests |
Requests in the unassigned state. Waiting to be enqueued. |
bool | freeing | Trunk is being freed, don't spawn new connections or re-enqueue. |
fr_dlist_head_t | full | Connections which have too many outstanding requests. |
trunk_io_funcs_t | funcs | I/O functions. |
void * | in_handler | Which handler we're inside. |
fr_dlist_head_t | inactive | Connections which have been signalled to be inactive by the API client. |
fr_dlist_head_t | inactive_draining | Connections which have been signalled to be inactive by the API client, which the trunk manager is draining to close. |
fr_dlist_head_t | init | Connections which have not yet started connecting. |
uint64_t | last_req_per_conn | The last request to connection ratio we calculated. |
fr_rate_limit_t | limit_last_failure_log | Rate limit on "Refusing to enqueue requests - No active conns". |
fr_rate_limit_t | limit_max_requests_alloc_log | Rate limit on "Refusing to alloc requests - Limit of * requests reached". |
char const * | log_prefix | What to prepend to messages. |
fr_event_timer_t const * | manage_ev | Periodic connection management event. |
bool | managing_connections | Whether the trunk is allowed to manage (open/close) connections. |
trunk_watch_entry_t * | next_watcher | Watcher about to be run. Used to prevent nested watchers. |
struct trunk_pub_s | pub |
Public fields in the trunk connection. This MUST be the first field in this structure. |
bool | started | Has the trunk been started. |
fr_dlist_head_t | to_free |
Connections we're done with and will free on the next call to trunk_manage. This prevents connections from being freed whilst we're inside callbacks. |
void * | uctx | Uctx data to pass to alloc. |
fr_dlist_head_t | watch[TRUNK_STATE_MAX] | To be called when trunk changes state. |
struct trunk_watch_entry_s |
Data Fields | ||
---|---|---|
bool | enabled | Whether the watch entry is enabled. |
fr_dlist_t | entry | List entry. |
trunk_watch_t | func |
Function to call when a trunk enters. the state this list belongs to |
bool | oneshot | Remove the function after it's called once. |
void * | uctx | User data to pass to the function. |
#define CALL_WATCHERS | ( | _trunk, | |
_state | |||
) |
Call the state change watch functions.
#define CONN_BAD_STATE_TRANSITION | ( | _new | ) |
#define CONN_REORDER | ( | _tconn | ) |
Reorder the connections in the active heap.
fr_heap_extract will also error out if heap_id is bad - no need for assert
#define CONN_STATE_TRANSITION | ( | _new, | |
_log | |||
) |
#define CONN_TRIGGER | ( | _state | ) |
#define COUNT_BY_STATE | ( | _state, | |
_list | |||
) |
#define DEQUEUE_ALL | ( | _src_list, | |
_state | |||
) |
#define DO_CONNECTION_ALLOC | ( | _tconn | ) |
Allocate a new connection.
#define DO_CONNECTION_NOTIFY | ( | _tconn, | |
_events | |||
) |
Change what events the connection should be notified about.
#define DO_REQUEST_CANCEL | ( | _treq, | |
_reason | |||
) |
Call the cancel callback if set.
#define DO_REQUEST_CANCEL_MUX | ( | _tconn | ) |
Write one or more cancellation requests to a connection.
#define DO_REQUEST_COMPLETE | ( | _treq | ) |
Call the complete callback (if set)
#define DO_REQUEST_CONN_RELEASE | ( | _treq | ) |
Call the "conn_release" callback (if set)
#define DO_REQUEST_DEMUX | ( | _tconn | ) |
Read one or more requests from a connection.
#define DO_REQUEST_FAIL | ( | _treq, | |
_prev_state | |||
) |
Call the fail callback (if set)
#define DO_REQUEST_FREE | ( | _treq | ) |
Call the free callback (if set)
#define DO_REQUEST_MUX | ( | _tconn | ) |
Write one or more requests to a connection.
#define IN_HANDLER | ( | _trunk | ) | (((_trunk)->in_handler) != NULL) |
#define IN_REQUEST_CANCEL_MUX | ( | _trunk | ) | (((_trunk)->funcs.request_cancel_mux) && ((_trunk)->in_handler == (void *)(_trunk)->funcs.request_cancel_mux)) |
#define IN_REQUEST_DEMUX | ( | _trunk | ) | (((_trunk)->funcs.request_demux) && ((_trunk)->in_handler == (void *)(_trunk)->funcs.request_demux)) |
#define IN_REQUEST_MUX | ( | _trunk | ) | (((_trunk)->funcs.request_mux) && ((_trunk)->in_handler == (void *)(_trunk)->funcs.request_mux)) |
#define IO_FUNC_VERIFY | ( | _func | ) | fr_fatal_assert_msg(trunk->funcs._func, "CONSISTENCY_CHECK_FAILED %s[%i}: " #_func " was NULL", file, line) |
#define IS_PROCESSING | ( | _tconn | ) | ((tconn)->pub.state & TRUNK_CONN_PROCESSING) |
#define IS_SERVICEABLE | ( | _tconn | ) | ((_tconn)->pub.state & TRUNK_CONN_SERVICEABLE) |
#define RECONNECT_BY_STATE | ( | _state, | |
_list | |||
) |
#define REQUEST_BAD_STATE_TRANSITION | ( | _new | ) |
#define REQUEST_EXTRACT_BACKLOG | ( | _treq | ) |
Remove the current request from the backlog.
#define REQUEST_EXTRACT_CANCEL | ( | _treq | ) | fr_dlist_remove(&tconn->cancel, treq) |
#define REQUEST_EXTRACT_CANCEL_PARTIAL | ( | _treq | ) |
#define REQUEST_EXTRACT_CANCEL_SENT | ( | _treq | ) | fr_dlist_remove(&tconn->cancel_sent, treq) |
#define REQUEST_EXTRACT_PARTIAL | ( | _treq | ) |
#define REQUEST_EXTRACT_PENDING | ( | _treq | ) |
Remove the current request from the pending list.
#define REQUEST_EXTRACT_REAPABLE | ( | _treq | ) | fr_dlist_remove(&tconn->reapable, treq) |
#define REQUEST_EXTRACT_SENT | ( | _treq | ) | fr_dlist_remove(&tconn->sent, treq) |
#define REQUEST_STATE_TRANSITION | ( | _new | ) |
Record a request state transition and log appropriate output.
#define REQUEST_TRIGGER | ( | _state | ) |
#define TCONN_DLIST_SEARCH | ( | _dlist | ) |
#define TCONN_DLIST_VERIFY | ( | _dlist, | |
_state | |||
) |
#define TCONN_MINMAX_HEAP_SEARCH | ( | _heap | ) |
#define TCONN_MINMAX_HEAP_VERIFY | ( | _heap, | |
_state | |||
) |
#define TCONN_TREQ_CHECKS | ( | _treq, | |
_state | |||
) |
#define TREQ_DLIST_SEARCH | ( | _dlist | ) |
#define TREQ_DLIST_VERIFY | ( | _dlist, | |
_state | |||
) |
#define TREQ_HEAP_SEARCH | ( | _heap | ) |
#define TREQ_HEAP_VERIFY | ( | _heap, | |
_state | |||
) |
#define TREQ_OPTION_SEARCH | ( | _option | ) |
#define TREQ_OPTION_VERIFY | ( | _option, | |
_state | |||
) |
#define TRUNK_REQUEST_STATE_LOG_MAX 20 |
#define TRUNK_STATE_TRANSITION | ( | _new | ) |
#define TRUNK_TCONN_CHECKS | ( | _tconn, | |
_state | |||
) |
typedef struct trunk_connection_s trunk_connection_t |
typedef struct trunk_request_s trunk_request_t |
typedef struct trunk_watch_entry_s trunk_watch_entry_t |
An entry in a trunk watch function list.
|
static |
|
static |
|
static |
|
static |
Connection failed after it was connected.
Reflect the connection state change in the lists we use to track connections.
[in] | conn | The connection which changes state. |
[in] | prev | The connection is was in. |
[in] | state | The connection is now in. |
[in] | uctx | The trunk_connection_t wrapping the connection. |
Definition at line 3487 of file trunk.c.
|
static |
Connection transitioned to the connected state.
Reflect the connection state change in the lists we use to track connections.
[in] | conn | The connection which changes state. |
[in] | prev | The connection is was in. |
[in] | state | The connection is now in. |
[in] | uctx | The trunk_connection_t wrapping the connection. |
Definition at line 3438 of file trunk.c.
|
static |
Connection transitioned to the connecting state.
Reflect the connection state change in the lists we use to track connections.
[in] | conn | The connection which changes state. |
[in] | prev | The connection is was in. |
[in] | state | The connection is now in. |
[in] | uctx | The trunk_connection_t wrapping the connection. |
Definition at line 3342 of file trunk.c.
|
static |
Connection failed.
[in] | conn | The connection which changes state. |
[in] | prev | The connection is was in. |
[in] | state | The connection is now in. |
[in] | uctx | The trunk_connection_t wrapping the connection. |
Definition at line 3558 of file trunk.c.
|
static |
Connection transitioned to the halted state.
Remove the connection remove all lists, as it's likely about to be freed.
Setting the trunk back to the init state ensures that if the code is ever refactored and connection_signal_reconnect is used after a connection is halted, then everything is maintained in a valid state.
[in] | conn | The connection which changes state. |
[in] | prev | The connection is was in. |
[in] | state | The connection is now in. |
[in] | uctx | The trunk_connection_t wrapping the connection. |
Definition at line 3610 of file trunk.c.
|
static |
Connection transitioned to the the init state.
Reflect the connection state change in the lists we use to track connections.
[in] | conn | The connection which changes state. |
[in] | prev | The connection is was in. |
[in] | state | The connection is now in. |
[in] | uctx | The trunk_connection_t wrapping the connection. |
Definition at line 3307 of file trunk.c.
|
static |
Connection transitioned to the shutdown state.
If we're not already in the draining-to-free state, transition there now.
The idea is that if something signalled the connection to shutdown, we need to reflect that by dequeuing any pending requests, not accepting new ones, and waiting for the existing requests to complete.
[in] | conn | The connection which changes state. |
[in] | prev | The connection is was in. |
[in] | state | The connection is now in. |
[in] | uctx | The trunk_connection_t wrapping the connection. |
Definition at line 3386 of file trunk.c.
|
static |
|
static |
|
static |
|
static |
Compare two protocol requests.
Allows protocol requests to be prioritised with a function specified by the API client. Defaults to by pointer address if no function is specified.
[in] | a | treq to compare to b. |
[in] | b | treq to compare to a. |
Definition at line 935 of file trunk.c.
|
static |
trunk_watch_entry_t* trunk_add_watch | ( | trunk_t * | trunk, |
trunk_state_t | state, | ||
trunk_watch_t | watch, | ||
bool | oneshot, | ||
void const * | uctx | ||
) |
Add a watch entry to the trunk state list.
[in] | trunk | The trunk to add the watcher to. |
[in] | state | to watch for. |
[in] | watch | Function to add. |
[in] | oneshot | Should this watcher only be run once. |
[in] | uctx | Context to pass to function. |
Definition at line 861 of file trunk.c.
trunk_t* trunk_alloc | ( | TALLOC_CTX * | ctx, |
fr_event_list_t * | el, | ||
trunk_io_funcs_t const * | funcs, | ||
trunk_conf_t const * | conf, | ||
char const * | log_prefix, | ||
void const * | uctx, | ||
bool | delay_start | ||
) |
Allocate a new collection of connections.
This function should be called first to allocate a new trunk connection.
After the trunk has been allocated, trunk_request_alloc and trunk_request_enqueue should be used to allocate memory for trunk requests, and pass a preq (protocol request) to the trunk for processing.
The trunk will then asynchronously process the request, writing the result to a specified rctx. See trunk_request_enqueue for more details.
[in] | ctx | To use for any memory allocations. Must be thread local. |
[in] | el | to use for I/O and timer events. |
[in] | funcs | Callback functions. |
[in] | conf | Common user configurable parameters. |
[in] | log_prefix | To prepend to global messages. |
[in] | uctx | User data to pass to the alloc function. |
[in] | delay_start | If true, then we will not spawn any connections until the first request is enqueued. |
Definition at line 4885 of file trunk.c.
|
static |
|
inlinestatic |
|
inlinestatic |
void trunk_connection_callback_readable | ( | UNUSED fr_event_list_t * | el, |
UNUSED int | fd, | ||
UNUSED int | flags, | ||
void * | uctx | ||
) |
Standard I/O read function.
Underlying FD in now readable, so call the trunk to read any pending requests from this connection.
[in] | el | The event list signalling. |
[in] | fd | that's now readable. |
[in] | flags | describing the read event. |
[in] | uctx | The trunk connection handle (tconn). |
Definition at line 3992 of file trunk.c.
void trunk_connection_callback_writable | ( | UNUSED fr_event_list_t * | el, |
UNUSED int | fd, | ||
UNUSED int | flags, | ||
void * | uctx | ||
) |
Standard I/O write function.
Underlying FD is now writable, so call the trunk to write any pending requests to this connection.
[in] | el | The event list signalling. |
[in] | fd | that's now writable. |
[in] | flags | describing the write event. |
[in] | uctx | The trunk connection handle (tcon). |
Definition at line 4009 of file trunk.c.
|
static |
Close connections in a particular connection list if they have no requests associated with them.
[in] | trunk | containing connections we want to close. |
[in] | head | of list of connections to examine. |
Definition at line 4035 of file trunk.c.
Return the count number of connections in the specified states.
[in] | trunk | to retrieve counts for. |
[in] | conn_state | One or more trunk_connection_state_t states or'd together. |
Definition at line 2843 of file trunk.c.
|
static |
|
static |
|
static |
|
static |
Transition a connection to the full state.
Called whenever a trunk connection is at the maximum number of requests. Removes the connection from the connected heap, and places it in the full list.
Definition at line 3093 of file trunk.c.
|
static |
|
static |
|
static |
bool trunk_connection_in_state | ( | trunk_connection_t * | tconn, |
int | state | ||
) |
|
inlinestatic |
Return whether a trunk connection should currently be considered full.
[in] | tconn | to check. |
Definition at line 2909 of file trunk.c.
int trunk_connection_manage_schedule | ( | trunk_t * | trunk | ) |
void trunk_connection_manage_start | ( | trunk_t * | trunk | ) |
void trunk_connection_manage_stop | ( | trunk_t * | trunk | ) |
int trunk_connection_pop_cancellation | ( | trunk_request_t ** | treq_out, |
trunk_connection_t * | tconn | ||
) |
Pop a cancellation request off a connection's cancellation queue.
The request we return is advanced by the request moving out of the cancel state and into the cancel_sent or cancel_complete state.
One of these signalling functions must be called after the request has been popped:
[out] | treq_out | to process |
[in] | tconn | Connection to drain cancellation request from. |
Definition at line 3813 of file trunk.c.
int trunk_connection_pop_request | ( | trunk_request_t ** | treq_out, |
trunk_connection_t * | tconn | ||
) |
Pop a request off a connection's pending queue.
The request we return is advanced by the request moving out of the partial or pending states, when the mux function signals us.
If the same request is returned again and again, it means the muxer isn't actually doing anything with the request we returned, and it's and error in the muxer code.
One of these signalling functions must be used after the request has been popped:
[out] | treq_out | to process |
[in] | tconn | to pop a request from. |
Definition at line 3861 of file trunk.c.
|
inlinestatic |
|
static |
|
static |
Shift requests in the specified states onto new connections.
This function will blindly dequeue any requests in the specified state and get them back to the unassigned state, cancelling any sent or partially sent requests.
This function does not check that dequeuing a request in a particular state is a sane or sensible thing to do, that's up to the caller!
[out] | out | A list to insert the newly dequeued and unassigned requests into. |
[in] | tconn | to dequeue requests from. |
[in] | states | Dequeue request in these states. |
[in] | max | The maximum number of requests to dequeue. 0 for unlimited. |
Definition at line 1730 of file trunk.c.
uint64_t trunk_connection_requests_requeue | ( | trunk_connection_t * | tconn, |
int | states, | ||
uint64_t | max, | ||
bool | fail_bound | ||
) |
Move requests off of a connection and requeue elsewhere.
[in] | tconn | to move requests off of. |
[in] | states | Only move requests in this state. |
[in] | max | The maximum number of requests to dequeue. 0 for unlimited. |
[in] | fail_bound | If true causes any requests bound to the connection to fail. If false bound requests will not be moved. |
Definition at line 2003 of file trunk.c.
|
static |
Remove requests in specified states from a connection, attempting to distribute them to new connections.
[in] | tconn | To remove requests from. |
[in] | states | One or more states or'd together. |
[in] | max | The maximum number of requests to dequeue. 0 for unlimited. |
[in] | fail_bound | If true causes any requests bound to the connection to fail. If false bound requests will not be moved. |
Definition at line 1841 of file trunk.c.
bool trunk_connection_search | ( | trunk_connection_t * | tconn, |
void * | ptr | ||
) |
void trunk_connection_signal_active | ( | trunk_connection_t * | tconn | ) |
void trunk_connection_signal_inactive | ( | trunk_connection_t * | tconn | ) |
void trunk_connection_signal_readable | ( | trunk_connection_t * | tconn | ) |
void trunk_connection_signal_reconnect | ( | trunk_connection_t * | tconn, |
connection_reason_t | reason | ||
) |
void trunk_connection_signal_writable | ( | trunk_connection_t * | tconn | ) |
Attempt to spawn a new connection.
Calls the API client's alloc() callback to create a new connection_t, then inserts the connection into the 'connecting' list.
[in] | trunk | to spawn connection in. |
[in] | now | The current time. |
Definition at line 3726 of file trunk.c.
void trunk_connection_verify | ( | char const * | file, |
int | line, | ||
trunk_connection_t * | tconn | ||
) |
|
inlinestatic |
int trunk_del_watch | ( | trunk_t * | trunk, |
trunk_state_t | state, | ||
trunk_watch_t | watch | ||
) |
Remove a watch function from a trunk state list.
[in] | trunk | The trunk to remove the watcher from. |
[in] | state | to remove the watch from. |
[in] | watch | Function to remove. |
Definition at line 827 of file trunk.c.
Implements the algorithm we use to manage requests per connection levels.
This is executed periodically using a timer event, and opens/closes connections.
The aim is to try and keep the request per connection level in a sweet spot, where there's enough outstanding work for the connection/pipelining to work efficiently, but not so much so that we encounter increased latency.
In the request enqueue and dequeue functions we record every time the average number of requests per connection goes above the target count and record every time the average number of requests per connection goes below the target count.
This may sound expensive, but in all cases we're just summing counters. CPU time required does not increase with additional requests, only with large numbers of connections.
If we do encounter scaling issues, we can always maintain the counters as aggregates as an optimisation later.
If when the management function runs, the trunk was above the target most recently, we:
If the trunk we below the target most recently, we:
Definition at line 4141 of file trunk.c.
|
static |
Rebalance connections across active trunk members when a new connection becomes active.
We don't have any visibility into the connection prioritisation algorithm it's essentially a black box.
We can however determine when the correct level of requests per connection has been reached, by dequeuing and requeing requests up until the point where the connection that just had a request dequeued, receives the same request back.
[in] | trunk | The trunk to rebalance. |
Definition at line 4077 of file trunk.c.
void trunk_reconnect | ( | trunk_t * | trunk, |
int | states, | ||
connection_reason_t | reason | ||
) |
Force the trunk to re-establish its connections.
[in] | trunk | to signal. |
[in] | states | One or more states or'd together. |
[in] | reason | Why the connections are being signalled to reconnect. |
Definition at line 4675 of file trunk.c.
trunk_request_t* trunk_request_alloc | ( | trunk_t * | trunk, |
request_t * | request | ||
) |
(Pre-)Allocate a new trunk request
If trunk->conf.req_pool_headers or trunk->conf.req_pool_size are not zero then the request will be a talloc pool, which can be used to hold the preq.
[in] | trunk | to add request to. |
[in] | request | to wrap in a trunk request (treq). |
Definition at line 2462 of file trunk.c.
|
static |
Check to see if a trunk request can be enqueued.
[out] | tconn_out | Connection the request may be enqueued on. |
[in] | trunk | To enqueue requests on. |
[in] | request | associated with the treq (if any). |
Definition at line 1595 of file trunk.c.
uint32_t trunk_request_count_by_connection | ( | trunk_connection_t const * | tconn, |
int | req_state | ||
) |
Return the count number of requests associated with a trunk connection.
[in] | tconn | to return request count for. |
[in] | req_state | One or more request states or'd together. |
Definition at line 2867 of file trunk.c.
uint64_t trunk_request_count_by_state | ( | trunk_t * | trunk, |
int | conn_state, | ||
int | req_state | ||
) |
Return a count of requests on a connection in a specific state.
[in] | trunk | to retrieve counts for. |
[in] | conn_state | One or more connection states or'd together. |
[in] | req_state | One or more request states or'd together. |
Definition at line 4472 of file trunk.c.
trunk_enqueue_t trunk_request_enqueue | ( | trunk_request_t ** | treq_out, |
trunk_t * | trunk, | ||
request_t * | request, | ||
void * | preq, | ||
void * | rctx | ||
) |
Enqueue a request that needs data written to the trunk.
When a request_t * needs to make an asynchronous request to an external datastore it should call this function, specifying a preq (protocol request) containing the data necessary to request information from the external datastore, and an rctx (resume ctx) used to hold the decoded response and/or any error codes.
After a treq is successfully enqueued it will either be assigned immediately to the pending queue of a connection, or if no connections are available, (depending on the trunk configuration) the treq will be placed in the trunk's global backlog.
After receiving a positive return code from this function the caller should immediately yield, to allow the various timers and I/O handlers that drive tconn (trunk connection) and treq state changes to be called.
When a tconn becomes writable (or the trunk is configured to be always writable) the trunk_request_mux_t callback will be called to dequeue, encode and send any pending requests for that tconn. The trunk_request_mux_t callback is also responsible for tracking the outbound requests to allow the trunk_request_demux_t callback to match inbound responses with the original treq. Once the trunk_request_mux_t callback is done processing the treq it signals what state the treq should enter next using one of the trunk_request_signal_* functions.
When a tconn becomes readable the user specified trunk_request_demux_t callback is called to process any responses, match them with the original treq. and signal what state they should enter next using one of the trunk_request_signal_* functions.
[in,out] | treq_out | A trunk request handle. If the memory pointed to is NULL, a new treq will be allocated. Otherwise treq should point to memory allocated with trunk_request_alloc. |
[in] | trunk | to enqueue request on. |
[in] | request | to enqueue. |
[in] | preq | Protocol request to write out. Will be freed when treq is freed. Should ideally be parented by the treq if possible. Use trunk_request_alloc for pre-allocation of the treq. |
[in] | rctx | The resume context to write any result to. |
Definition at line 2575 of file trunk.c.
|
static |
Enqueue a request which has never been assigned to a connection or was previously cancelled.
[in] | treq | to re enqueue. Must have been removed from its existing connection with trunk_connection_requests_dequeue. |
Definition at line 1673 of file trunk.c.
trunk_enqueue_t trunk_request_enqueue_on_conn | ( | trunk_request_t ** | treq_out, |
trunk_connection_t * | tconn, | ||
request_t * | request, | ||
void * | preq, | ||
void * | rctx, | ||
bool | ignore_limits | ||
) |
Enqueue additional requests on a specific connection.
This may be used to create a series of requests on a single connection, or to generate in-band status checks.
[in,out] | treq_out | A trunk request handle. If the memory pointed to is NULL, a new treq will be allocated. Otherwise treq should point to memory allocated with trunk_request_alloc. |
[in] | tconn | to enqueue request on. |
[in] | request | to enqueue. |
[in] | preq | Protocol request to write out. Will be freed when treq is freed. Should ideally be parented by the treq if possible. Use trunk_request_alloc for pre-allocation of the treq. |
[in] | rctx | The resume context to write any result to. |
[in] | ignore_limits | Ignore max_req_per_conn. Useful to force status checks through even if the connection is at capacity. Will also allow enqueuing on "inactive", "draining", "draining-to-free" connections. |
Definition at line 2729 of file trunk.c.
|
static |
Transition a request to the backlog state, adding it to the backlog of the trunk.
[in] | treq | to trigger a state change for. |
[in] | new | Whether this is a new request. |
Definition at line 1088 of file trunk.c.
|
static |
Transition a request to the cancel state, placing it in a connection's cancellation list.
If a request_cancel_send callback is provided, that callback will be called periodically for requests which were cancelled due to a signal.
The request_cancel_send callback will dequeue cancelled requests and inform a remote server that the result is no longer required.
A request must enter this state before being added to the backlog of another connection if it's been sent or partially sent.
[in] | treq | to trigger a state change for. |
[in] | reason | Why the request was cancelled. Should be one of:
|
Definition at line 1366 of file trunk.c.
|
static |
Cancellation was acked, the request is complete, free it.
The API client will not be informed, as the original request_t * will likely have been freed by this point.
[in] | treq | to mark as complete. |
Definition at line 1497 of file trunk.c.
|
static |
Transition a request to the cancel_partial state, placing it in a connection's cancel_partial slot.
The request_demux function is then responsible for signalling that the cancel request is complete when the remote server acknowledges the cancellation request.
[in] | treq | to trigger a state change for. |
Definition at line 1417 of file trunk.c.
|
static |
Transition a request to the cancel_sent state, placing it in a connection's cancel_sent list.
The request_demux function is then responsible for signalling that the cancel request is complete when the remote server acknowledges the cancellation request.
[in] | treq | to trigger a state change for. |
Definition at line 1452 of file trunk.c.
|
static |
Request completed successfully, inform the API client and free the request.
[in] | treq | to mark as complete. |
Definition at line 1528 of file trunk.c.
|
static |
Request failed, inform the API client and free the request.
[in] | treq | to mark as failed. |
Definition at line 1559 of file trunk.c.
|
static |
|
static |
Transition a request to the pending state, adding it to the backlog of an active connection.
All trunk requests being added to a connection get passed to this function. All trunk requests being removed from a connection get passed to trunk_request_remove_from_conn.
[in] | treq | to trigger a state change for. |
[in] | tconn | to enqueue the request on. |
[in] | new | Whether this is a new request. |
Definition at line 1150 of file trunk.c.
|
static |
Transition a request to the reapable state, indicating that it's been sent in its entirety, but no response is expected.
[in] | treq | to trigger a state change for. |
Definition at line 1304 of file trunk.c.
|
static |
Transition a request to the sent state, indicating that it's been sent in its entirety.
[in] | treq | to trigger a state change for. |
Definition at line 1251 of file trunk.c.
|
static |
Transition a request to the unassigned state, in preparation for re-assignment.
[in] | treq | to trigger a state change for. |
Definition at line 1053 of file trunk.c.
void trunk_request_free | ( | trunk_request_t ** | treq_to_free | ) |
If the trunk request is freed then update the target requests.
gperftools showed calling the request free function directly was slightly faster than using talloc_free.
[in] | treq_to_free | request. |
Definition at line 2310 of file trunk.c.
|
static |
Remove a request from all connection lists.
A common function used by init, fail, complete state functions to disassociate a request from a connection in preparation for freeing or reassignment.
Despite its unassuming name, this function is the place to put calls to functions which need to be called when the number of requests associated with a connection changes.
Trunk requests will always be passed to this function before they're removed from a connection, even if the requests are being freed.
[in] | treq | to trigger a state change for. |
Definition at line 959 of file trunk.c.
trunk_enqueue_t trunk_request_requeue | ( | trunk_request_t * | treq | ) |
Re-enqueue a request on the same connection.
If the treq has been sent, we assume that we're being signalled to requeue because something outside of the trunk API has determined that a retransmission is required. The easiest way to perform that retransmission is to clean up any tracking information for the request, and the requeue it for transmission.
IF re-queueing fails, the request will enter the fail state. It should not be accessed if this occurs.
[in] | treq | to requeue (retransmit). |
Definition at line 2664 of file trunk.c.
bool trunk_request_search | ( | trunk_request_t * | treq, |
void * | ptr | ||
) |
void trunk_request_signal_cancel | ( | trunk_request_t * | treq | ) |
Cancel a trunk request.
treq can be in any state, but requests to cancel if the treq is not in the TRUNK_REQUEST_STATE_PARTIAL or TRUNK_REQUEST_STATE_SENT state will be ignored.
The complete or failed callbacks will not be called here, as it's assumed the request_t * is now inviable as it's being cancelled.
The free function however, is called, and that should be used to perform necessary cleanup.
[in] | treq | to signal state change for. |
Definition at line 2140 of file trunk.c.
void trunk_request_signal_cancel_complete | ( | trunk_request_t * | treq | ) |
Signal that a remote server acked our cancellation.
Called from request_demux to indicate that it got an ack for the cancellation.
[in] | treq | to signal state change for. |
Definition at line 2272 of file trunk.c.
void trunk_request_signal_cancel_partial | ( | trunk_request_t * | treq | ) |
void trunk_request_signal_cancel_sent | ( | trunk_request_t * | treq | ) |
Signal that a remote server has been notified of the cancellation.
Called from request_cancel_mux to indicate that the datastore has been informed that the response is no longer needed.
[in] | treq | to signal state change for. |
Definition at line 2248 of file trunk.c.
void trunk_request_signal_complete | ( | trunk_request_t * | treq | ) |
void trunk_request_signal_fail | ( | trunk_request_t * | treq | ) |
void trunk_request_signal_partial | ( | trunk_request_t * | treq | ) |
void trunk_request_signal_reapable | ( | trunk_request_t * | treq | ) |
void trunk_request_signal_sent | ( | trunk_request_t * | treq | ) |
void trunk_request_state_log | ( | fr_log_t const * | log, |
fr_log_type_t | log_type, | ||
char const * | file, | ||
int | line, | ||
trunk_request_t const * | treq | ||
) |
void trunk_request_state_log_entry_add | ( | char const * | function, |
int | line, | ||
trunk_request_t * | treq, | ||
trunk_request_state_t | new | ||
) |
void trunk_request_verify | ( | char const * | file, |
int | line, | ||
trunk_request_t * | treq | ||
) |
|
static |
Update timestamps for when we last had a transition from above target to below target or vice versa.
Should be called on every time a connection or request is allocated or freed.
[out] | conn_count_out | How many connections we considered. |
[out] | req_count_out | How many requests we considered. |
[in] | trunk | to operate on. |
[in] | now | The current time. |
[in] | verify | if true (and this is a debug build), then assert if req_per_conn has changed. |
Definition at line 4521 of file trunk.c.
int trunk_start | ( | trunk_t * | trunk | ) |
void trunk_verify | ( | char const * | file, |
int | line, | ||
trunk_t * | trunk | ||
) |
Verify a trunk.
A trunk has some number of connections, which each have some number of requests. The connections and requests are in differing kinds of containers depending on their state and how they are used, and may have fields that can only be validated by comparison with a parent. We had planned on passing a "context" down with the ancestral values, but that breaks the foo_verify() API. Each foo_verify() will only verify the foo's children.
Definition at line 4966 of file trunk.c.
|
inlinestatic |
|
static |
|
static |
|
static |
conf_parser_t const trunk_config[] |
Config parser definitions to populate a trunk_conf_t.
|
static |
|
static |
|
static |
Map connection states to trigger names.
Must stay in the same order as trunk_connection_state_t
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Map request states to trigger names.
Must stay in the same order as trunk_connection_state_t
|
static |
|
static |
|
static |
|
static |
|
static |