/** @name State
* @{
*/
- fr_trunk_connection_state_t state; //!< What state the connection is in.
-
-
fr_trunk_connection_event_t events; //!< The current events we expect to be notified on.
/** @} */
do { \
INFO("[%" PRIu64 "] Trunk connection changed state %s -> %s", \
tconn->pub.conn->id, \
- fr_table_str_by_value(fr_trunk_connection_states, tconn->state, "<INVALID>"), \
+ fr_table_str_by_value(fr_trunk_connection_states, tconn->pub.state, "<INVALID>"), \
fr_table_str_by_value(fr_trunk_connection_states, _new, "<INVALID>")); \
- tconn->state = _new; \
+ tconn->pub.state = _new; \
trunk_requests_per_connnection(NULL, NULL, trunk, fr_time()); \
} while (0)
do { \
if (!fr_cond_assert_msg(0, "[%" PRIu64 "] Trunk connection invalid transition %s -> %s", \
tconn->pub.conn->id, \
- fr_table_str_by_value(fr_trunk_connection_states, tconn->state, "<INVALID>"), \
+ fr_table_str_by_value(fr_trunk_connection_states, tconn->pub.state, "<INVALID>"), \
fr_table_str_by_value(fr_trunk_connection_states, _new, "<INVALID>"))) return; \
} while (0)
#define IN_REQUEST_DEMUX(_trunk) (((_trunk)->funcs.request_demux) && ((_trunk)->in_handler == (void *)(_trunk)->funcs.request_demux))
#define IN_REQUEST_CANCEL_MUX(_trunk) (((_trunk)->funcs.request_cancel_mux) && ((_trunk)->in_handler == (void *)(_trunk)->funcs.request_cancel_mux))
-#define IS_SERVICEABLE(_tconn) ((_tconn)->state & FR_TRUNK_CONN_SERVICEABLE)
+#define IS_SERVICEABLE(_tconn) ((_tconn)->pub.state & FR_TRUNK_CONN_SERVICEABLE)
/** Remove the current request from the backlog
*
do { \
int _ret; \
if ((fr_heap_num_elements((_tconn)->pub.trunk->active) == 1)) break; \
- if (!fr_cond_assert((_tconn)->state == FR_TRUNK_CONN_ACTIVE)) break; \
+ if (!fr_cond_assert((_tconn)->pub.state == FR_TRUNK_CONN_ACTIVE)) break; \
_ret = fr_heap_extract((_tconn)->pub.trunk->active, (_tconn)); \
if (!fr_cond_assert(_ret == 0)) break; \
fr_heap_insert((_tconn)->pub.trunk->active, (_tconn)); \
DEBUG4("[%" PRIu64 "] Trunk connection released request %" PRIu64, tconn->pub.conn->id, treq->id);
- switch (tconn->state){
+ switch (tconn->pub.state){
case FR_TRUNK_CONN_FULL:
trunk_connection_auto_unfull(tconn); /* Check if we can switch back to active */
- if (tconn->state == FR_TRUNK_CONN_FULL) break; /* Only fallthrough if conn is now active */
+ if (tconn->pub.state == FR_TRUNK_CONN_FULL) break; /* Only fallthrough if conn is now active */
/* FALL-THROUGH */
case FR_TRUNK_CONN_ACTIVE:
* Reorder the connection in the heap now it has an
* additional request.
*/
- if (tconn->state == FR_TRUNK_CONN_ACTIVE) CONN_REORDER(tconn);
+ if (tconn->pub.state == FR_TRUNK_CONN_ACTIVE) CONN_REORDER(tconn);
/*
* We have a new request, see if we need to register
* to record its state now, before removing all the
* requests from it.
*/
- state = tconn->state;
+ state = tconn->pub.state;
/*
* Prevent requests being requeued on the same trunk
*/
uint64_t fr_trunk_connection_requests_requeue(fr_trunk_connection_t *tconn, int states, uint64_t max, bool fail_bound)
{
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_ACTIVE:
case FR_TRUNK_CONN_FULL:
case FR_TRUNK_CONN_INACTIVE:
(fr_trunk_request_count_by_connection(tconn, FR_TRUNK_REQUEST_STATE_ALL) >=
trunk->conf.max_req_per_conn)) return FR_TRUNK_ENQUEUE_NO_CAPACITY;
- if (tconn->state != FR_TRUNK_CONN_ACTIVE) return FR_TRUNK_ENQUEUE_NO_CAPACITY;
+ if (tconn->pub.state != FR_TRUNK_CONN_ACTIVE) return FR_TRUNK_ENQUEUE_NO_CAPACITY;
}
if (*treq_out) {
fr_trunk_t *trunk = tconn->pub.trunk;
uint32_t count;
- if (tconn->state != FR_TRUNK_CONN_ACTIVE) return;
+ if (tconn->pub.state != FR_TRUNK_CONN_ACTIVE) return;
/*
* Enforces max_req_per_conn
*/
static inline void trunk_connection_auto_unfull(fr_trunk_connection_t *tconn)
{
- if (tconn->state != FR_TRUNK_CONN_FULL) return;
+ if (tconn->pub.state != FR_TRUNK_CONN_FULL) return;
/*
* Enforces max_req_per_conn
fr_trunk_t *trunk = tconn->pub.trunk;
fr_trunk_connection_event_t events = FR_TRUNK_CONN_EVENT_NONE;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
/*
* We only register I/O events if the trunk connection is
* in one of these states.
fr_trunk_t *trunk = tconn->pub.trunk;
int ret;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_ACTIVE:
ret = fr_heap_extract(trunk->active, tconn);
if (!fr_cond_assert(ret == 0)) return;
{
fr_trunk_t *trunk = tconn->pub.trunk;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_ACTIVE:
trunk_connection_remove(tconn);
break;
{
fr_trunk_t *trunk = tconn->pub.trunk;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_ACTIVE:
case FR_TRUNK_CONN_FULL:
trunk_connection_remove(tconn);
{
fr_trunk_t *trunk = tconn->pub.trunk;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_ACTIVE:
case FR_TRUNK_CONN_FULL:
case FR_TRUNK_CONN_INACTIVE:
{
fr_trunk_t *trunk = tconn->pub.trunk;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_ACTIVE:
case FR_TRUNK_CONN_FULL:
case FR_TRUNK_CONN_INACTIVE:
{
fr_trunk_t *trunk = tconn->pub.trunk;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_FULL:
case FR_TRUNK_CONN_INACTIVE:
case FR_TRUNK_CONN_DRAINING:
fr_trunk_connection_t *tconn = talloc_get_type_abort(uctx, fr_trunk_connection_t);
fr_trunk_t *trunk = tconn->pub.trunk;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_HALTED:
break;
fr_trunk_connection_t *tconn = talloc_get_type_abort(uctx, fr_trunk_connection_t);
fr_trunk_t *trunk = tconn->pub.trunk;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_INIT:
case FR_TRUNK_CONN_CLOSED:
trunk_connection_remove(tconn);
{
fr_trunk_connection_t *tconn = talloc_get_type_abort(uctx, fr_trunk_connection_t);
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_DRAINING_TO_FREE: /* Do Nothing */
return;
fr_trunk_t *trunk = tconn->pub.trunk;
bool need_requeue = false;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_ACTIVE:
case FR_TRUNK_CONN_FULL:
case FR_TRUNK_CONN_INACTIVE:
fr_trunk_t *trunk = tconn->pub.trunk;
bool need_requeue = false;
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_ACTIVE:
case FR_TRUNK_CONN_FULL:
case FR_TRUNK_CONN_INACTIVE:
*/
static int _trunk_connection_free(fr_trunk_connection_t *tconn)
{
- rad_assert(tconn->state == FR_TRUNK_CONN_HALTED);
+ rad_assert(tconn->pub.state == FR_TRUNK_CONN_HALTED);
rad_assert(!fr_dlist_entry_in_list(&tconn->entry)); /* Should not be in a list */
/*
*/
MEM(tconn = talloc_zero(trunk, fr_trunk_connection_t));
tconn->pub.trunk = trunk;
- tconn->state = FR_TRUNK_CONN_HALTED; /* All connections start in the halted state */
+ tconn->pub.state = FR_TRUNK_CONN_HALTED; /* All connections start in the halted state */
/*
* Allocate a new fr_connection_t or fail.
{
/* Can be called anywhere */
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_ACTIVE:
case FR_TRUNK_CONN_FULL:
trunk_connection_enter_inactive(tconn);
*/
void fr_trunk_connection_signal_active(fr_trunk_connection_t *tconn)
{
- switch (tconn->state) {
+ switch (tconn->pub.state) {
case FR_TRUNK_CONN_FULL:
trunk_connection_auto_unfull(tconn); /* Mark as active if it should be active */
break;
*/
bool fr_trunk_connection_in_state(fr_trunk_connection_t *tconn, int state)
{
- return (bool)(tconn->state & state);
+ return (bool)(tconn->pub.state & state);
}
/** Rebalance connections across active trunk members when a new connection becomes active