We now use the one associated with the interpreter. Requests don't have event lists... interpreters do. There were some instances where request->el wasn't being inherited correctly, this fixes that.
return client;
}
-static request_t *request_from_file(TALLOC_CTX *ctx, FILE *fp, RADCLIENT *client,
- CONF_SECTION *server_cs, fr_event_list_t *el)
+static request_t *request_from_file(TALLOC_CTX *ctx, FILE *fp, RADCLIENT *client, CONF_SECTION *server_cs)
{
fr_pair_t *vp;
request_t *request;
request->client = client;
request->number = number++;
request->name = talloc_typed_asprintf(request, "%" PRIu64, request->number);
- request->el = el;
request->master_state = REQUEST_ACTIVE;
/*
/*
* Grab the VPs from stdin, or from the file.
*/
- request = request_from_file(autofree, fp, client, server_cs, el);
+ request = request_from_file(autofree, fp, client, server_cs);
if (!request) {
fr_perror("Failed reading input from %s", input_file);
EXIT_WITH_FAILURE;
}
if (count == 1) {
- unlang_interpret_synchronous(request);
+ unlang_interpret_synchronous(el, request);
} else {
int i;
request_t *old = request_clone(request);
for (i = 0; i < count; i++) {
request = request_clone(old);
- unlang_interpret_synchronous(request);
+ unlang_interpret_synchronous(el, request);
talloc_free(request);
}
}
static inline CC_HINT(always_inline)
void worker_request_init(fr_worker_t *worker, request_t *request, fr_time_t now)
{
- request->el = worker->el;
-
/*
* For internal requests request->packet
* and request->reply are already populated.
* Ensure that we can clean up any child processes. We
* don't want them left over as zombies.
*/
- if (fr_event_pid_reap(request->el, pid, NULL, NULL) < 0) {
+ if (fr_event_pid_reap(unlang_interpret_event_list(request), pid, NULL, NULL) < 0) {
int status;
/*
void fr_exec_cleanup(fr_exec_state_t *exec, int signal)
{
request_t *request = exec->request;
+ fr_event_list_t *el = unlang_interpret_event_list(request);
if (exec->pid) RDEBUG3("Cleaning up exec state for pid %u", exec->pid);
}
if (exec->stdout_fd >= 0) {
- if (fr_event_fd_delete(request->el, exec->stdout_fd, FR_EVENT_FILTER_IO) < 0){
+ if (fr_event_fd_delete(el, exec->stdout_fd, FR_EVENT_FILTER_IO) < 0){
RPERROR("Failed removing stdout handler");
}
close(exec->stdout_fd);
}
if (exec->stderr_fd >= 0) {
- if (fr_event_fd_delete(request->el, exec->stderr_fd, FR_EVENT_FILTER_IO) < 0) {
+ if (fr_event_fd_delete(el, exec->stderr_fd, FR_EVENT_FILTER_IO) < 0) {
RPERROR("Failed removing stderr handler");
}
close(exec->stderr_fd);
if (exec->pid >= 0) {
if (signal > 0) kill(exec->pid, signal);
- if (unlikely(fr_event_pid_reap(request->el, exec->pid, NULL, NULL) < 0)) {
+ if (unlikely(fr_event_pid_reap(el, exec->pid, NULL, NULL) < 0)) {
int status;
RPERROR("Failed setting up async PID reaper, PID %u may now be a zombie", exec->pid);
* We've received EOF - so the process has finished writing
* Remove event and tidy up
*/
- (void) fr_event_fd_delete(exec->request->el, fd, FR_EVENT_FILTER_IO);
+ (void) fr_event_fd_delete(unlang_interpret_event_list(exec->request), fd, FR_EVENT_FILTER_IO);
close(fd);
exec->stdout_fd = -1;
bool store_stdout, TALLOC_CTX *stdout_ctx,
fr_time_delta_t timeout)
{
- int *stdout_fd = (store_stdout || RDEBUG_ENABLED2) ? &exec->stdout_fd : NULL;
+ int *stdout_fd = (store_stdout || RDEBUG_ENABLED2) ? &exec->stdout_fd : NULL;
+ fr_event_list_t *el = unlang_interpret_event_list(request);
*exec = (fr_exec_state_t){
.request = request,
/*
* Tell the event loop that it needs to wait for this PID
*/
- if (fr_event_pid_wait(ctx, request->el, &exec->ev_pid, exec->pid, exec_reap, exec) < 0) {
+ if (fr_event_pid_wait(ctx, el, &exec->ev_pid, exec->pid, exec_reap, exec) < 0) {
exec->pid = -1;
RPEDEBUG("Failed adding watcher for child process");
/*
* Setup event to kill the child process after a period of time.
*/
- if ((timeout > 0) && fr_event_timer_in(ctx, request->el, &exec->ev,
+ if ((timeout > 0) && fr_event_timer_in(ctx, el, &exec->ev,
timeout, exec_timeout, exec) < 0) goto fail_and_close;
/*
* Accept a maximum of 32k of data from the process.
*/
fr_sbuff_init_talloc(exec->stdout_ctx, &exec->stdout_buff, &exec->stdout_tctx, 128, 32 * 1024);
- if (fr_event_fd_insert(ctx, request->el, exec->stdout_fd, exec_stdout_read, NULL, NULL, exec) < 0) {
+ if (fr_event_fd_insert(ctx, el, exec->stdout_fd, exec_stdout_read, NULL, NULL, exec) < 0) {
RPEDEBUG("Failed adding event listening to stdout");
goto fail_and_close;
}
.prefix = exec->stdout_prefix
};
- if (fr_event_fd_insert(ctx, request->el, exec->stdout_fd, log_request_fd_event,
+ if (fr_event_fd_insert(ctx, el, exec->stdout_fd, log_request_fd_event,
NULL, NULL, &exec->stdout_uctx) < 0){
RPEDEBUG("Failed adding event listening to stdout");
goto fail_and_close;
.prefix = exec->stderr_prefix
};
- if (fr_event_fd_insert(ctx, request->el, exec->stderr_fd, log_request_fd_event,
+ if (fr_event_fd_insert(ctx, el, exec->stderr_fd, log_request_fd_event,
NULL, NULL, &exec->stderr_uctx) < 0) {
RPEDEBUG("Failed adding event listening to stderr");
close(exec->stderr_fd);
close(stderr_pipe[1]);
}
} else {
- (void) fr_event_pid_wait(request->el, request->el, NULL, pid, NULL, NULL);
+ fr_event_list_t *el = unlang_interpret_event_list(request);
+
+ (void) fr_event_pid_wait(el, el, NULL, pid, NULL, NULL);
}
return pid;
fr_radius_packet_t *packet; //!< Incoming request.
fr_radius_packet_t *reply; //!< Outgoing response.
- fr_event_list_t *el; //!< thread-specific event list.
-
RADCLIENT *client; //!< The client that originally sent us the request.
request_master_state_t master_state; //!< Set by the master thread to signal the child that's currently
* with something like the server
* shutting down.
*/
- unlang_interpret_synchronous(child);
+ unlang_interpret_synchronous(unlang_interpret_event_list(request), child);
talloc_free(child);
}
if (unlang_interpret_push_section(request, subcs, RLM_MODULE_REJECT, UNLANG_TOP_FRAME) < 0) {
RETURN_MODULE_FAIL;
}
- rcode = unlang_interpret_synchronous(request);
+ rcode = unlang_interpret_synchronous(unlang_interpret_event_list(request), request);
request->component = component;
request->module = module;
if (instruction->actions.retry.mrd) {
retry->timeout = fr_time() + instruction->actions.retry.mrd;
- if (fr_event_timer_at(retry, request->el, &retry->ev, retry->timeout,
+ if (fr_event_timer_at(retry, unlang_interpret_event_list(request), &retry->ev, retry->timeout,
instruction_timeout_handler, request) < 0) {
RPEDEBUG("Failed inserting event");
goto fail;
return stack->intp;
}
+/** Get the event list for the current interpreter
+ *
+ */
+fr_event_list_t *unlang_interpret_event_list(request_t *request)
+{
+ unlang_stack_t *stack = request->stack;
+
+ if (!stack->intp) return NULL;
+
+ return stack->intp->el;
+}
+
/** Set the default interpreter for this thread
*
*/
unlang_interpret_t *unlang_interpret_get(request_t *request);
+fr_event_list_t *unlang_interpret_event_list(request_t *request);
+
void unlang_interpret_set_thread_default(unlang_interpret_t *intp);
unlang_interpret_t *unlang_interpret_get_thread_default(void);
rlm_rcode_t unlang_interpret(request_t *request) CC_HINT(hot);
-rlm_rcode_t unlang_interpret_synchronous(request_t *request);
+rlm_rcode_t unlang_interpret_synchronous(fr_event_list_t *el, request_t *request);
void *unlang_interpret_stack_alloc(TALLOC_CTX *ctx);
* @param[in] request The current request.
* @return One of the RLM_MODULE_* macros.
*/
-rlm_rcode_t unlang_interpret_synchronous(request_t *request)
+rlm_rcode_t unlang_interpret_synchronous(fr_event_list_t *el, request_t *request)
{
- fr_event_list_t *old_el;
unlang_interpret_t *old_intp;
char const *caller;
bool dont_wait_for_event;
int iterations = 0;
- old_el = request->el;
old_intp = unlang_interpret_get(request);
caller = request->module;
- intps = unlang_interpret_synchronous_alloc(request, request->el);
- request->el = intps->el;
+ intps = unlang_interpret_synchronous_alloc(request, el);
unlang_interpret_set(request, intps->intp);
rcode = unlang_interpret(request);
* well.
*/
DEBUG3("Gathering events - %s", dont_wait_for_event ? "Will not wait" : "will wait");
- num_events = fr_event_corral(request->el, fr_time(), !dont_wait_for_event);
+ num_events = fr_event_corral(el, fr_time(), !dont_wait_for_event);
if (num_events < 0) {
RPERROR("fr_event_corral");
break;
*/
if (num_events > 0) {
DEBUG4("Servicing event(s)");
- fr_event_service(request->el);
+ fr_event_service(el);
}
/*
talloc_free(intps);
unlang_interpret_set(request, old_intp);
- request->el = old_el;
request->module = caller;
return rcode;
* Initialize some basic information for the child.
*/
child->number = parent->number;
- child->el = parent->el;
/*
* Initialize all of the async fields.
}
if (ev->fd >= 0) {
- if (!ev->request || !ev->request->el) return 0;
-
- (void) fr_event_fd_delete(ev->request->el, ev->fd, FR_EVENT_FILTER_IO);
+ if (!ev->request) return 0;
+ (void) fr_event_fd_delete(unlang_interpret_event_list(ev->request), ev->fd, FR_EVENT_FILTER_IO);
}
return 0;
.ctx = ctx
};
- if (fr_event_timer_at(request, request->el, &ev->ev,
+ if (fr_event_timer_at(request, unlang_interpret_event_list(request), &ev->ev,
when, unlang_module_event_timeout_handler, ev) < 0) {
RPEDEBUG("Failed inserting event");
talloc_free(ev);
/*
* Register for events on the file descriptor
*/
- if (fr_event_fd_insert(request, request->el, fd,
+ if (fr_event_fd_insert(request, unlang_interpret_event_list(request), fd,
ev->fd_read ? unlang_event_fd_read_handler : NULL,
ev->fd_write ? unlang_event_fd_write_handler : NULL,
ev->fd_error ? unlang_event_fd_error_handler: NULL,
/*
* Reset the timer.
*/
- if (fr_event_timer_at(request, request->el, &state->ev, state->retry.next,
+ if (fr_event_timer_at(request, unlang_interpret_event_list(request), &state->ev, state->retry.next,
unlang_module_event_retry_handler, request) < 0) {
RPEDEBUG("Failed inserting event");
unlang_interpret_mark_runnable(request); /* and let the caller figure out what's up */
(void) fr_retry_init(&state->retry, now, &frame->instruction->actions.retry); /* can't fail */
- if (fr_event_timer_at(request, request->el, &state->ev, state->retry.next,
+ if (fr_event_timer_at(request, unlang_interpret_event_list(request),
+ &state->ev, state->retry.next,
unlang_module_event_retry_handler, request) < 0) {
RPEDEBUG("Failed inserting event");
goto fail;
ev_p = talloc_size(request, sizeof(*ev_p));
memset(ev_p, 0, sizeof(*ev_p));
- if (fr_event_timer_in(request, request->el, ev_p, when,
+ if (fr_event_timer_in(request, unlang_interpret_event_list(request), ev_p, when,
unlang_detached_max_request_time, request) < 0) {
talloc_free(ev_p);
return -1;
}
if (ev->fd >= 0) {
- (void) fr_event_fd_delete(ev->request->el, ev->fd, FR_EVENT_FILTER_IO);
+ (void) fr_event_fd_delete(unlang_interpret_event_list(ev->request), ev->fd, FR_EVENT_FILTER_IO);
}
return 0;
ev->thread = xlat_thread_instance_find(state->exp);
ev->ctx = ctx;
- if (fr_event_timer_at(request, request->el, &ev->ev, when, unlang_xlat_event_timeout_handler, ev) < 0) {
+ if (fr_event_timer_at(request, unlang_interpret_event_list(request),
+ &ev->ev, when, unlang_xlat_event_timeout_handler, ev) < 0) {
RPEDEBUG("Failed inserting event");
talloc_free(ev);
return -1;
return NULL;
}
- switch (unlang_interpret_synchronous(request)) {
+ switch (unlang_interpret_synchronous(unlang_interpret_event_list(request), request)) {
default:
break;
talloc_free(request);
return 0;
}
- unlang_interpret_synchronous(request);
+ unlang_interpret_synchronous(unlang_interpret_event_list(request), request);
DEBUG("}");
/*
FALL_THROUGH;
case REQUEST_RECV:
- rcode = unlang_interpret_synchronous(request);
+ rcode = unlang_interpret_synchronous(unlang_interpret_event_list(request), request);
if (request->master_state == REQUEST_STOP_PROCESSING) goto done;
FALL_THROUGH;
ret = -1;
goto finish;
}
- rcode = unlang_interpret_synchronous(request);
+ rcode = unlang_interpret_synchronous(unlang_interpret_event_list(request), request);
switch (rcode) {
case RLM_MODULE_OK:
case RLM_MODULE_UPDATED:
eap_session_t *eap_session = eap_session_get(request->parent);
eap_round_t *eap_round = eap_session->this_round;
- rcode = unlang_interpret_synchronous(request);
+ rcode = unlang_interpret_synchronous(unlang_interpret_event_list(request), request);
if (request->master_state == REQUEST_STOP_PROCESSING) return UNLANG_ACTION_STOP_PROCESSING;
rlm_rcode_t rcode;
eap_session_t *eap_session = eap_session_get(request->parent);
- rcode = unlang_interpret_synchronous(request);
+ rcode = unlang_interpret_synchronous(unlang_interpret_event_list(request), request);
if (request->master_state == REQUEST_STOP_PROCESSING) return UNLANG_ACTION_STOP_PROCESSING;
if (unlang_interpret_push_section(request, unlang, RLM_MODULE_FAIL, UNLANG_TOP_FRAME) < 0) {
RETURN_MODULE_FAIL;
}
- rcode = unlang_interpret_synchronous(request);
+ rcode = unlang_interpret_synchronous(unlang_interpret_event_list(request), request);
}
return mschap_finalize(p_result, mctx, request, eap_session, rcode);
* Status-Server checks. Manually build the packet, and
* all of its associated glue.
*/
-static void CC_HINT(nonnull) status_check_alloc(fr_event_list_t *el, udp_handle_t *h)
+static void CC_HINT(nonnull) status_check_alloc(udp_handle_t *h)
{
udp_request_t *u;
request_t *request;
talloc_const_free(request->name);
request->name = talloc_strdup(request, h->module_name);
- request->el = el;
request->packet = fr_radius_packet_alloc(request, false);
request->reply = fr_radius_packet_alloc(request, false);
* status-check response.
*/
if (h->inst->parent->status_check) {
- status_check_alloc(conn->el, h);
+ status_check_alloc(h);
/*
* Start status checking.