};
static size_t fr_trunk_connection_events_len = NUM_ELEMENTS(fr_trunk_connection_events);
+#define TRIGGER(name) do { \
+ if (trunk->pub.triggers) { \
+ trigger_exec(NULL, NULL, "trunk." STRINGIFY(name), true, NULL); \
+ } \
+} while (0)
+
#define CONN_STATE_TRANSITION(_new, _log) \
do { \
_log("[%" PRIu64 "] Trunk connection changed state %s -> %s", \
fr_dlist_insert_head(&trunk->full, tconn);
CONN_STATE_TRANSITION(FR_TRUNK_CONN_FULL, DEBUG2);
+ TRIGGER(full);
}
/** Transition a connection to the inactive state
fr_dlist_insert_head(&trunk->inactive, tconn);
CONN_STATE_TRANSITION(FR_TRUNK_CONN_INACTIVE, DEBUG2);
+ TRIGGER(inactive);
}
/** Transition a connection to the inactive-draining state
fr_dlist_insert_head(&trunk->inactive_draining, tconn);
CONN_STATE_TRANSITION(FR_TRUNK_CONN_INACTIVE_DRAINING, INFO);
+ TRIGGER(inactive_draining);
/*
* Immediately re-enqueue all pending
fr_dlist_insert_head(&trunk->draining, tconn);
CONN_STATE_TRANSITION(FR_TRUNK_CONN_DRAINING, INFO);
+ TRIGGER(draining);
/*
* Immediately re-enqueue all pending
fr_dlist_insert_head(&trunk->draining_to_free, tconn);
CONN_STATE_TRANSITION(FR_TRUNK_CONN_DRAINING_TO_FREE, INFO);
+ TRIGGER(draining_to_free);
/*
* Immediately re-enqueue all pending
MEM(fr_heap_insert(trunk->active, tconn) == 0); /* re-insert into the active heap*/
CONN_STATE_TRANSITION(FR_TRUNK_CONN_ACTIVE, DEBUG2);
+ TRIGGER(active);
/*
* Reorder the connections
fr_dlist_insert_head(&trunk->init, tconn);
CONN_STATE_TRANSITION(FR_TRUNK_CONN_INIT, DEBUG2);
+ TRIGGER(init);
}
/** Connection transitioned to the connecting state
fr_dlist_insert_head(&trunk->connecting, tconn); /* MUST remain a head insertion for reconnect logic */
CONN_STATE_TRANSITION(FR_TRUNK_CONN_CONNECTING, INFO);
+ TRIGGER(connecting);
}
/** Connection transitioned to the shutdown state
fr_dlist_insert_head(&trunk->closed, tconn); /* MUST remain a head insertion for reconnect logic */
CONN_STATE_TRANSITION(FR_TRUNK_CONN_CLOSED, INFO);
+ TRIGGER(closed);
/*
* Now *AFTER* the connection has been
* and will end life in the halted state.
*/
CONN_STATE_TRANSITION(FR_TRUNK_CONN_HALTED, DEBUG2);
+ TRIGGER(halted);
/*
* There should be no requests left on this