From: Arran Cudbard-Bell Date: Mon, 21 Jul 2025 20:52:51 +0000 (-0700) Subject: Fix trigger plumbing in connection.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0edb46bc2399dab6207c16af378b5679504bdfdb;p=thirdparty%2Ffreeradius-server.git Fix trigger plumbing in connection.c --- diff --git a/src/lib/server/connection.c b/src/lib/server/connection.c index 045041cd0fe..91d4f9c837a 100644 --- a/src/lib/server/connection.c +++ b/src/lib/server/connection.c @@ -121,13 +121,14 @@ struct connection_s { ///< 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, ""), true, NULL); \ - } \ + trigger(unlang_interpret_get_thread_default(), \ + conn->trigger_cs, fr_table_str_by_value(connection_trigger_names, _state, ""), true, conn->trigger_args); \ } while (0) #define STATE_TRANSITION(_new) \ @@ -1517,10 +1518,10 @@ static int _connection_free(connection_t *conn) * - 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; @@ -1547,6 +1548,8 @@ connection_t *connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, .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)); @@ -1563,7 +1566,7 @@ connection_t *connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, * 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; diff --git a/src/lib/server/connection.h b/src/lib/server/connection.h index d75ea982f64..cd913ddb55a 100644 --- a/src/lib/server/connection.h +++ b/src/lib/server/connection.h @@ -31,6 +31,8 @@ extern "C" { #include #include #include +#include +#include #ifdef _CONST # error _CONST can only be defined in the local header @@ -77,7 +79,6 @@ struct connection_pub_s { ///< 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 { @@ -92,6 +93,12 @@ typedef struct { 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;