27RCSID(
"$Id: c8efa28e7637bb174298605681b77f810b9c4e87 $")
29#include <freeradius-devel/server/rcode.h>
30#include <freeradius-devel/server/signal.h>
31#include <freeradius-devel/server/state.h>
32#include <freeradius-devel/server/request.h>
33#include <freeradius-devel/util/table.h>
99 RDEBUG3(
"parallel - child %s (%d/%d) CANCELLED, previously %s",
147 RDEBUG3(
"parallel - child %s (%d/%d) DONE",
176 RDEBUG4(
"** [%i] %s - over-riding result from higher priority to (%s %d)",
196 *p_result = state->
result;
220 MEM(frame->
state = state = _talloc_zero_pooled_object(request,
223 "unlang_parallel_state_t",
225 (talloc_array_length(request->name) * 2)));
241 for (i = 0, instruction = g->
children; instruction != NULL; i++, instruction = instruction->
next) {
245 request->proto_dict, state->
detach);
246 child->packet->code = request->packet->code;
248 RDEBUG3(
"parallel - child %s (%d/%d) INIT",
260 &child->request_pairs,
261 &request->request_pairs) < 0) ||
264 &request->reply_pairs) < 0) ||
266 &child->control_pairs,
267 &request->control_pairs) < 0)) {
268 REDEBUG(
"failed copying lists to child");
275 for (--i; i >= 0; i--) {
325 RDEBUG3(
"parallel - child %s (%d/%d) DETACHED",
Unlang interpreter actions.
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
@ UNLANG_ACTION_YIELD
Temporarily pause execution until an event occurs.
fr_table_num_ordered_t const unlang_child_states_table[]
int unlang_child_request_init(TALLOC_CTX *ctx, unlang_child_request_t *out, request_t *child, rlm_rcode_t *p_result, unsigned int *sibling_count, void const *unique_session_ptr, bool free_child)
Initialize a child request.
struct unlang_child_request_t::@100 config
request_t * request
Child request. The actual request the child will run.
char const * name
Cache the request name.
unlang_child_request_state_t state
State of the child.
unlang_child_request_state_t
Parallel child states.
@ CHILD_RUNNABLE
Running/runnable.
@ CHILD_DETACHED
Child has detached, we can't signal it or communicate with it anymore.
@ CHILD_INIT
Initial state, has no request allocated.
@ CHILD_EXITED
Child has run to completion, and is waiting to be reaped.
@ CHILD_CANCELLED
Child was cancelled.
@ CHILD_FREED
The child has been freed.
@ CHILD_DONE
The child has been processed by the parent the request should still exist, and should be freed.
Each child has a state, a number, a request, and a count of their siblings.
fr_table_num_sorted_t const mod_rcode_table[]
bool unlang_request_is_scheduled(request_t const *request)
Return whether a request is currently scheduled.
int unlang_interpret_push(request_t *request, unlang_t const *instruction, rlm_rcode_t default_rcode, bool do_next_sibling, bool top_frame)
Push a new frame onto the stack.
void unlang_interpret_signal(request_t *request, fr_signal_t action)
Send a signal (usually stop) to a request.
Declarations for the unlang interpreter.
Private declarations for the unlang interpreter.
static void interpret_child_init(request_t *request)
#define RDEBUG_ENABLED3
True if request debug level 1-3 messages are enabled.
void unlang_register(int type, unlang_op_t *op)
Register an operation with the interpreter.
request_t * unlang_io_subrequest_alloc(request_t *parent, fr_dict_t const *namespace, bool detachable)
Allocate a child request based on the parent.
int fr_pair_list_copy(TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
Duplicate a list of pairs.
static unlang_action_t unlang_parallel(rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
void unlang_parallel_init(void)
static unlang_action_t unlang_parallel_resume(rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
static void unlang_parallel_cancel_child(unlang_parallel_state_t *state, unlang_child_request_t *cr)
Cancel a specific child.
static void unlang_parallel_signal(UNUSED request_t *request, unlang_stack_frame_t *frame, fr_signal_t action)
Send a signal from parent request to all of it's children.
Declarations for the unlang "parallel" keyword.
bool detach
are we creating the child detached
static unlang_parallel_t * unlang_group_to_parallel(unlang_group_t *g)
Cast a group structure to the parallel keyword extension.
unsigned int num_runnable
How many children are complete.
bool clone
are the children cloned
bool detach
are we creating the child detached
unlang_child_request_t children[]
Array of children.
unsigned int num_children
How many children are executing.
#define RETURN_MODULE_FAIL
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_REJECT
Immediately reject the request.
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
#define REQUEST_VERIFY(_x)
void fr_state_restore_to_child(request_t *child, void const *unique_ptr, int unique_int)
Restore subrequest data from a parent request.
fr_signal_t
Signals that can be generated/processed by request signal handlers.
@ FR_SIGNAL_CANCEL
Request has been cancelled.
@ FR_SIGNAL_DETACH
Request is being detached from its parent.
void unlang_subrequest_detach_and_free(request_t **child)
Free a child request, detaching it from its parent and freeing allocated memory.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
Private interpreter structures and functions.
unlang_t * next
Next node (executed on UNLANG_ACTION_EXECUTE_NEXT et al).
void * state
Stack frame specialisations.
static unlang_group_t * unlang_generic_to_group(unlang_t const *p)
static unlang_stack_frame_t * frame_current(request_t *request)
static int stack_depth_current(request_t *request)
@ UNLANG_TYPE_PARALLEL
execute statements in parallel
static void frame_repeat(unlang_stack_frame_t *frame, unlang_process_t process)
Mark the current stack frame up for repeat, and set a new process function.
unlang_t const * instruction
The unlang node we're evaluating.
@ UNLANG_OP_FLAG_DEBUG_BRACES
Print debug braces.
@ UNLANG_OP_FLAG_RCODE_SET
Set request->rcode to the result of this operation.
@ UNLANG_OP_FLAG_NO_CANCEL
Must not be cancelled.
unlang_t * children
Children beneath this group.
Generic representation of a grouping.
A node in a graph of unlang_op_t (s) that we execute.
Our interpreter stack, as distinct from the C stack.
An unlang stack associated with a request.