25#include <freeradius-devel/server/state.h>
26#include <freeradius-devel/server/request.h>
27#include <freeradius-devel/server/signal.h>
80 cr->
config.session_unique_ptr,
83 RDEBUG3(
"Detached - Removing subrequest from parent, and marking parent as runnable");
145 if (cr->
config.session_unique_ptr) {
147 cr->
config.session_unique_ptr,
157 cr->
result.rcode = *p_result;
167 if (cr->
config.session_unique_ptr) {
173 fr_assert_msg(0,
"child %s resumed top frame with invalid state %s",
184 RDEBUG3(
"All children have exited, marking parent %s as runnable", request->parent->name);
187 RDEBUG3(
"Child %s exited, %u sibling(s) remaining",
215 .name =
"child-request",
216 .debug_name =
"child-request-resume",
239 state = frame->
state;
266 rlm_rcode_t *p_result,
unsigned int *sibling_count,
void const *unique_session_ptr,
bool free_child)
270 .num = sibling_count ? (*sibling_count)++ : 0,
273 .sibling_count = sibling_count,
275 .session_unique_ptr = unique_session_ptr,
276 .free_child = free_child
279 .p_result = p_result,
291 .name =
"child-request",
307 .frame_state_type =
"unlang_frame_state_child_request_t"
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.
#define L(_str)
Helper for initialising arrays of string literals.
static unlang_action_t unlang_child_request_done(rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
When the child is done, tell the parent that we've exited.
unlang_child_request_t * cr
A pointer to memory in the parent's frame state allocated for this child to write results to.
int unlang_child_request_op_init(void)
fr_table_num_ordered_t const unlang_child_states_table[]
static void unlang_child_request_signal(request_t *request, UNUSED unlang_stack_frame_t *frame, fr_signal_t action)
Process a detach signal in the child.
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.
static int unlang_child_request_stack_init(unlang_child_request_t *cr)
Push a resumption frame onto a child's stack.
size_t unlang_child_states_table_len
struct unlang_child_request_t::@100 config
request_t * request
Child request. The actual request the child will run.
struct unlang_child_request_t::@101 result
unlang_child_request_state_t state
State of the child.
unsigned int * sibling_count
Number of siblings.
@ 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_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.
#define fr_assert_msg(_x, _msg,...)
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code...
int unlang_interpret_push_instruction(request_t *request, void *instruction, rlm_rcode_t default_rcode, bool top_frame)
Push an instruction onto the request stack for later interpretation.
void unlang_interpret_mark_runnable(request_t *request)
Mark a request as resumable.
void unlang_register(int type, unlang_op_t *op)
Register an operation with the interpreter.
Return codes returned by modules and virtual server sections.
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_INVALID
The module considers the request invalid.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
@ RLM_MODULE_REJECT
Immediately reject the request.
@ RLM_MODULE_NOTFOUND
User not found.
@ RLM_MODULE_UPDATED
OK (pairs modified).
@ RLM_MODULE_NOT_SET
Error resolving rcode (should not be returned by modules).
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
#define request_is_detached(_x)
void fr_state_discard_child(request_t *parent, void const *unique_ptr, int unique_int)
Remove state from a child.
void fr_state_store_in_parent(request_t *child, void const *unique_ptr, int unique_int)
Store subrequest's session-state list and persistable request data in its parent.
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.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
An element in an arbitrarily ordered array of name to num mappings.
char * talloc_bstrdup(TALLOC_CTX *ctx, char const *in)
Binary safe strdup function.
Functions which we wish were included in the standard talloc distribution.
Private interpreter structures and functions.
static void repeatable_clear(unlang_stack_frame_t *frame)
void * state
Stack frame specialisations.
int priority
Result priority.
static unlang_stack_frame_t * frame_current(request_t *request)
@ UNLANG_TYPE_CHILD_REQUEST
a frame at the top of a child's request stack used to signal the parent when the child is complete.
@ UNLANG_OP_FLAG_NO_CANCEL
Must not be cancelled.
static void repeatable_set(unlang_stack_frame_t *frame)
unlang_type_t type
The specialisation of this node.
A node in a graph of unlang_op_t (s) that we execute.
Our interpreter stack, as distinct from the C stack.
static size_t char ** out