The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Functions | Variables
subrequest_child.c File Reference
#include <freeradius-devel/server/state.h>
#include "interpret_priv.h"
#include "subrequest_child_priv.h"
+ Include dependency graph for subrequest_child.c:

Go to the source code of this file.

Functions

static void unlang_detached_max_request_time (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
 Event handler to free a detached child. More...
 
static unlang_action_t unlang_subrequest_calculate_result (UNUSED rlm_rcode_t *p_result, UNUSED request_t *request, unlang_stack_frame_t *frame)
 Function to run in the context of the parent on resumption. More...
 
static unlang_action_t unlang_subrequest_child_done (rlm_rcode_t *p_result, UNUSED int *p_priority, request_t *request, void *uctx)
 When the child is done, tell the parent that we've exited. More...
 
void unlang_subrequest_child_op_free (void)
 
int unlang_subrequest_child_op_init (void)
 
int unlang_subrequest_child_push (rlm_rcode_t *out, request_t *child, unlang_subrequest_session_t const *session, bool free_child, bool top_frame)
 Push a pre-existing child back onto the stack as a subrequest. More...
 
int unlang_subrequest_child_push_and_detach (request_t *request)
 
int unlang_subrequest_child_push_resume (request_t *child, unlang_frame_state_subrequest_t *state)
 Push a resumption frame onto a child's stack. More...
 
unlang_action_t unlang_subrequest_child_run (UNUSED rlm_rcode_t *p_result, UNUSED request_t *request, unlang_stack_frame_t *frame)
 Function called by the unlang interpreter to start the child running. More...
 
static void unlang_subrequest_child_signal (request_t *request, fr_signal_t action, UNUSED void *uctx)
 Process a detach signal in the child. More...
 
int unlang_subrequest_lifetime_set (request_t *request)
 Initialize a detached child. More...
 

Variables

static fr_dict_t const * dict_freeradius
 
static fr_dict_attr_t const * request_attr_request_lifetime
 
fr_dict_autoload_t subrequest_dict []
 
fr_dict_attr_autoload_t subrequest_dict_attr []
 
static unlang_subrequest_tsubrequest_instruction
 Holds a synthesised instruction that we insert into the parent request. More...
 

Function Documentation

◆ unlang_detached_max_request_time()

static void unlang_detached_max_request_time ( UNUSED fr_event_list_t el,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Event handler to free a detached child.

Definition at line 53 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_calculate_result()

static unlang_action_t unlang_subrequest_calculate_result ( UNUSED rlm_rcode_t p_result,
UNUSED request_t request,
unlang_stack_frame_t frame 
)
static

Function to run in the context of the parent on resumption.

Definition at line 242 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_child_done()

static unlang_action_t unlang_subrequest_child_done ( rlm_rcode_t p_result,
UNUSED int *  p_priority,
request_t request,
void *  uctx 
)
static

When the child is done, tell the parent that we've exited.

This is pushed as a frame at the top of the child's stack, so when the child is done executing, it runs this to inform the parent that its done.

Definition at line 168 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_child_op_free()

void unlang_subrequest_child_op_free ( void  )

Definition at line 430 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_child_op_init()

int unlang_subrequest_child_op_init ( void  )

Definition at line 386 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_child_push()

int unlang_subrequest_child_push ( rlm_rcode_t out,
request_t child,
unlang_subrequest_session_t const *  session,
bool  free_child,
bool  top_frame 
)

Push a pre-existing child back onto the stack as a subrequest.

The child MUST have been allocated with unlang_io_subrequest_alloc, or something that calls it.

After the child is no longer required it MUST be freed with unlang_subrequest_detach_and_free. It's not enough to free it with talloc_free.

This function should be called before pushing any additional frames onto the child's stack for it to execute.

The parent should return UNLANG_ACTION_PUSHED_CHILD, when it's done setting up the child request. It should NOT return UNLANG_ACTION_YIELD.

Parameters
[in]outWhere to write the result of the subrequest.
[in]childto push.
[in]sessioncontrol values. Whether we restore/store session info.
[in]free_childautomatically free the child when it's finished executing. This is useful if extracting the result from the child is done using the child's stack, and so the parent never needs to access it.
[in]top_frameSet to UNLANG_TOP_FRAME if the interpreter should return. Set to UNLANG_SUB_FRAME if the interprer should continue.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 325 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_child_push_and_detach()

int unlang_subrequest_child_push_and_detach ( request_t request)

Definition at line 369 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_child_push_resume()

int unlang_subrequest_child_push_resume ( request_t child,
unlang_frame_state_subrequest_t state 
)

Push a resumption frame onto a child's stack.

This is necessary so that the child informs its parent when it's done/detached and so that the child responds to detach signals.

Definition at line 222 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_child_run()

unlang_action_t unlang_subrequest_child_run ( UNUSED rlm_rcode_t p_result,
UNUSED request_t request,
unlang_stack_frame_t frame 
)

Function called by the unlang interpreter to start the child running.

The reason why we do this on the unlang stack is so that this frame is marked as resumable in the parent, not whatever frame was previously being processed by the interpreter when the parent was called.

i.e. after calling unlang_subrequest_child_push, the code in the parent can call UNLANG_ACTION_PUSHED_CHILD, which will result in this frame being executed, and this frame can yield.

Definition at line 262 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_child_signal()

static void unlang_subrequest_child_signal ( request_t request,
fr_signal_t  action,
UNUSED void *  uctx 
)
static

Process a detach signal in the child.

This processes any detach signals the child receives The child doesn't actually do the detaching

Definition at line 112 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_subrequest_lifetime_set()

int unlang_subrequest_lifetime_set ( request_t request)

Initialize a detached child.

Detach it from the parent, set up it's lifetime, and mark it as runnable.

Definition at line 67 of file subrequest_child.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 34 of file subrequest_child.c.

◆ request_attr_request_lifetime

fr_dict_attr_t const* request_attr_request_lifetime
static

Definition at line 42 of file subrequest_child.c.

◆ subrequest_dict

fr_dict_autoload_t subrequest_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ NULL }
}
static fr_dict_t const * dict_freeradius

Definition at line 37 of file subrequest_child.c.

◆ subrequest_dict_attr

fr_dict_attr_autoload_t subrequest_dict_attr
Initial value:
= {
{ .out = &request_attr_request_lifetime, .name = "Request-Lifetime", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
{ NULL }
}
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
static fr_dict_attr_t const * request_attr_request_lifetime

Definition at line 45 of file subrequest_child.c.

◆ subrequest_instruction

unlang_subrequest_t* subrequest_instruction
static

Holds a synthesised instruction that we insert into the parent request.

Definition at line 32 of file subrequest_child.c.