///< the connection.
unsigned int signals_pause; //!< Temporarily stop processing of signals.
+
+ CONF_SECTION *trigger_cs; //!< Where to search locally for triggers.
+ fr_pair_list_t *trigger_args; //!< Arguments to pass to the trigger functions.
};
#define CONN_TRIGGER(_state) do { \
- if (conn->pub.triggers) { \
- trigger(unlang_interpret_get_thread_default(), \
- NULL, fr_table_str_by_value(connection_trigger_names, _state, "<INVALID>"), true, NULL); \
- } \
+ trigger(unlang_interpret_get_thread_default(), \
+ conn->trigger_cs, fr_table_str_by_value(connection_trigger_names, _state, "<INVALID>"), true, conn->trigger_args); \
} while (0)
#define STATE_TRANSITION(_new) \
* - NULL on failure.
*/
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)
+ connection_funcs_t const *funcs,
+ connection_conf_t const *conf,
+ char const *log_prefix,
+ void const *uctx)
{
size_t i;
connection_t *conn;
.failed = funcs->failed,
.shutdown = funcs->shutdown,
.is_closed = true, /* Starts closed */
+ .trigger_args = conf->trigger_args,
+ .trigger_cs = conf->trigger_cs,
.pub.name = talloc_asprintf(conn, "%s - [%" PRIu64 "]", log_prefix, id)
};
memcpy(&conn->uctx, &uctx, sizeof(conn->uctx));
* Pre-allocate a on_halt watcher for deferred signal processing
*/
conn->on_halted = connection_add_watch_post(conn, CONNECTION_STATE_HALTED,
- _deferred_signal_connection_on_halted, true, NULL);
+ _deferred_signal_connection_on_halted, true, NULL);
connection_watch_disable(conn->on_halted); /* Start disabled */
return conn;
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/talloc.h>
+#include <freeradius-devel/util/pair.h>
+#include <freeradius-devel/server/cf_util.h>
#ifdef _CONST
# error _CONST can only be defined in the local header
///< re-establish this connection.
uint64_t _CONST timed_out; //!< How many times has this connection timed out when
///< connecting.
- bool _CONST triggers; //!< do we run the triggers?
};
typedef enum {
fr_time_delta_t connection_timeout; //!< How long to wait for the connection to open
//!< or for shutdown to close the connection.
fr_time_delta_t reconnection_delay; //!< How long to wait after failures.
+
+ CONF_SECTION *trigger_cs; //!< Local configuration section we also search for triggers in.
+ ///< Lifetime must be longer than the connection.
+
+ fr_pair_list_t *trigger_args; //!< Additional pairs to pass to the trigger function
+ ///< Lifetime must be longer than the connection.
} connection_conf_t;
typedef struct connection_watch_entry_s connection_watch_entry_t;