* @param[in] now The current time.
* @param[in] ctx User ctx passed to #fr_event_timer_insert.
*/
-typedef void (*fr_event_callback_t)(struct timeval *now, void *ctx);
+typedef void (*fr_event_callback_t)(fr_event_list_t *el, struct timeval *now, void *ctx);
/** Called after each event loop cycle
*
EVENT_CORRAL_AUX //!< Maybe main thread or one shared by modules
} event_corral_t;
-fr_event_list_t *radius_event_list_corral(event_corral_t hint);
+fr_event_list_t *process_global_event_list(event_corral_t hint);
int radius_event_init(TALLOC_CTX *ctx);
int radius_event_start(bool spawn_flag);
void radius_event_free(void);
int radius_event_process(void);
void radius_update_listener(rad_listen_t *listener);
-void revive_home_server(struct timeval *now, void *ctx);
+void revive_home_server(fr_event_list_t *el, struct timeval *now, void *ctx);
void mark_home_server_dead(home_server_t *home, struct timeval *when);
/* evaluate.c */
*/
fr_event_timer_delete(el, ev->parent);
- callback(when, ctx);
+ callback(el, when, ctx);
return 1;
}
goto do_splice;
}
+ case 'T':
+ {
+ struct timeval *in = va_arg(ap_q, struct timeval *);
+
+ subst = talloc_asprintf(NULL, "%" PRIu64 ".%06" PRIu64,
+ (uint64_t)in->tv_sec,
+ (uint64_t)in->tv_usec);
+ if (!subst) goto oom;
+
+ goto do_splice;
+ }
+
default:
(void) va_arg(ap_q, void *); /* void * */
}
}
if (strcmp(argv[last], "alive") == 0) {
- revive_home_server(NULL, home);
+ revive_home_server(NULL, NULL, home);
} else if (strcmp(argv[last], "dead") == 0) {
struct timeval now;
static void mark_home_server_alive(REQUEST *request, home_server_t *home);
-fr_event_list_t *radius_event_list_corral(UNUSED event_corral_t hint) {
+fr_event_list_t *process_global_event_list(UNUSED event_corral_t hint) {
/* Currently we do not run a second event loop for modules. */
return el;
}
*/
#define STATE_MACHINE_DECL(_x) static void _x(REQUEST *request, fr_state_action_t action)
-static void request_timer(struct timeval *now, void *ctx);
+static void request_timer(fr_event_list_t *eel, struct timeval *now, void *ctx);
/** Insert #REQUEST back into the event heap, to continue executing at a future time
*
/*
* Callback for ALL timer events related to the request.
*/
-static void request_timer(UNUSED struct timeval *now, void *ctx)
+static void request_timer(UNUSED fr_event_list_t *eel, UNUSED struct timeval *now, void *ctx)
{
REQUEST *request = talloc_get_type_abort(ctx, REQUEST);
#ifdef DEBUG_STATE_MACHINE
/*
* Timer function for all TCP sockets.
*/
-static void tcp_socket_timer(struct timeval *now, void *ctx)
+static void tcp_socket_timer(UNUSED fr_event_list_t *eel, struct timeval *now, void *ctx)
{
rad_listen_t *listener = talloc_get_type_abort(ctx, rad_listen_t);
listen_socket_t *sock = listener->data;
* Called from start of zombie period, OR after control socket
* marks the home server dead.
*/
-static void ping_home_server(struct timeval *now, void *ctx)
+static void ping_home_server(UNUSED fr_event_list_t *eel, struct timeval *now, void *ctx)
{
home_server_t *home = talloc_get_type_abort(ctx, home_server_t);
REQUEST *request;
buffer, sizeof(buffer)),
home->port, (int) response_window->tv_sec, (int) response_window->tv_usec);
- ping_home_server(now, home);
+ ping_home_server(el, now, home);
}
struct timeval now;
gettimeofday(&now, NULL);
- ping_home_server(&now, home);
+ ping_home_server(el, &now, home);
} else {
DEBUG("PING: Already pinging home server %s", home->log_name);
}
}
-void revive_home_server(UNUSED struct timeval *now, void *ctx)
+void revive_home_server(UNUSED fr_event_list_t *eel, UNUSED struct timeval *now, void *ctx)
{
home_server_t *home = talloc_get_type_abort(ctx, home_server_t);
char buffer[INET6_ADDRSTRLEN];
/** Process stats for a single interval
*
*/
-static void rs_stats_process(struct timeval *now, void *ctx)
+static void rs_stats_process(fr_event_list_t *el, struct timeval *now, void *ctx)
{
size_t i;
size_t rs_codes_len = (sizeof(rs_useful_codes) / sizeof(*rs_useful_codes));
now->tv_sec += conf->stats.interval;
now->tv_usec = 0;
- if (fr_event_timer_insert(this->list, rs_stats_process, ctx, now, &event) < 0) {
+ if (fr_event_timer_insert(el, rs_stats_process, ctx, now, &event) < 0) {
ERROR("Failed inserting stats interval event");
}
}
talloc_free(request);
}
-static void _rs_event(UNUSED struct timeval *now, void *ctx)
+static void _rs_event(UNUSED fr_event_list_t *el, UNUSED struct timeval *now, void *ctx)
{
rs_request_t *request = talloc_get_type_abort(ctx, rs_request_t);
request->event = NULL;
/** Re-open the collectd socket
*
*/
-static void rs_collectd_reopen(struct timeval *now, void *ctx)
+static void rs_collectd_reopen(fr_event_list_t *el, struct timeval *now, UNUSED void *ctx)
{
- fr_event_list_t *list = ctx;
static fr_event_timer_t *event;
struct timeval when;
ERROR("Will attempt to re-establish connection in %i ms", RS_SOCKET_REOPEN_DELAY);
rs_tv_add_ms(now, RS_SOCKET_REOPEN_DELAY, &when);
- if (fr_event_timer_insert(list, rs_collectd_reopen, list, &when, &event) < 0) {
+ if (fr_event_timer_insert(el, rs_collectd_reopen, el, &when, &event) < 0) {
ERROR("Failed inserting re-open event");
RS_ASSERT(0);
}
struct timeval now;
gettimeofday(&now, NULL);
- rs_collectd_reopen(&now, list);
+ rs_collectd_reopen(list, &now, list);
}
break;
#else
/*
* Enforce max_request_time.
*/
-static void max_request_time_hook(UNUSED struct timeval *now, void *ctx)
+static void max_request_time_hook(UNUSED fr_event_list_t *el, UNUSED struct timeval *now, void *ctx)
{
REQUEST *request = talloc_get_type_abort(ctx, REQUEST);
#ifdef DEBUG_STATE_MACHINE
thread = module_thread_instance_find(sp->module_instance);
rad_assert(thread != NULL);
-
+
return thread->active_callers;
}
-
+
case UNLANG_TYPE_GROUP:
case UNLANG_TYPE_LOAD_BALANCE:
case UNLANG_TYPE_REDUNDANT_LOAD_BALANCE:
thread = module_thread_instance_find(sp->module_instance);
rad_assert(thread != NULL);
-
+
active_callers = thread->active_callers;
RDEBUG3("load-balance child %d sub-module has %" PRIu64 " active", num, active_callers);
}
/** Call the callback registered for a timeout event
*
+ * @param[in] el the event timer was inserted into.
* @param[in] now The current time, as held by the event_list.
* @param[in] ctx unlang_event_t structure holding callbacks.
*
*/
-static void unlang_event_timeout_handler(struct timeval *now, void *ctx)
+static void unlang_event_timeout_handler(UNUSED fr_event_list_t *el, struct timeval *now, void *ctx)
{
unlang_event_t *ev = talloc_get_type_abort(ctx, unlang_event_t);
void *mutable_ctx;
return RLM_MODULE_YIELD;
}
-static void unlang_timer_hook(UNUSED struct timeval *now, void *ctx)
+static void unlang_timer_hook(UNUSED fr_event_list_t *el, UNUSED struct timeval *now, void *ctx)
{
REQUEST *request = talloc_get_type_abort(ctx, REQUEST);
#ifdef DEBUG_STATE_MACHINE
static int bfd_start_packets(bfd_state_t *session);
static int bfd_start_control(bfd_state_t *session);
static int bfd_stop_control(bfd_state_t *session);
-static void bfd_detection_timeout(struct timeval *now, void *ctx);
+static void bfd_detection_timeout(UNUSED fr_event_list_t *eel, struct timeval *now, void *ctx);
static int bfd_process(bfd_state_t *session, bfd_packet_t *bfd);
static fr_event_list_t *el = NULL; /* don't ask */
/*
* Send a packet.
*/
-static void bfd_send_packet(UNUSED struct timeval *now, void *ctx)
+static void bfd_send_packet(UNUSED fr_event_list_t *eel, UNUSED struct timeval *now, void *ctx)
{
bfd_state_t *session = ctx;
bfd_packet_t bfd;
}
-static void bfd_detection_timeout(struct timeval *now, void *ctx)
+static void bfd_detection_timeout(UNUSED fr_event_list_t *eel, struct timeval *now, void *ctx)
{
bfd_state_t *session = ctx;
/** libcurl's timer expired
*
+ * @param[in] el the timer was inserted into.
* @param[in] now The current time according to the event loop.
* @param[in] ctx The rlm_rest_thread_t specific to this thread.
*/
-static void _rest_io_timer_expired(UNUSED struct timeval *now, void *ctx)
+static void _rest_io_timer_expired(UNUSED fr_event_list_t *el, UNUSED struct timeval *now, void *ctx)
{
rlm_rest_thread_t *t;
char k[64]; /* To silence const warns until newer unbound in distros */
- inst->el = radius_event_list_corral(EVENT_CORRAL_AUX);
+ inst->el = process_global_event_list(EVENT_CORRAL_AUX);
inst->log_pipe_stream[0] = NULL;
inst->log_pipe_stream[1] = NULL;
inst->log_fd = -1;