The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Functions
subrequest.c File Reference

Unlang "subrequest" and "detach" keyword evaluation. More...

#include <freeradius-devel/server/state.h>
#include <freeradius-devel/server/tmpl_dcursor.h>
#include <freeradius-devel/server/request.h>
#include <freeradius-devel/unlang/action.h>
#include "unlang_priv.h"
#include "interpret_priv.h"
#include "subrequest_priv.h"
#include "child_request_priv.h"
+ Include dependency graph for subrequest.c:

Go to the source code of this file.

Functions

request_tunlang_subrequest_alloc (request_t *parent, fr_dict_t const *namespace)
 Allocate a subrequest to run through a virtual server at some point in the future.
 
static unlang_action_t unlang_subrequest_child_done (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.
 
int unlang_subrequest_child_push (request_t *child, rlm_rcode_t *p_result, void const *unique_session_ptr, bool free_child, bool top_frame)
 Push a pre-existing child back onto the stack as a subrequest.
 
int unlang_subrequest_child_push_and_detach (request_t *request)
 Add a child request to the runnable queue.
 
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, or manually to start the child running.
 
void unlang_subrequest_detach_and_free (request_t **child)
 Free a child request, detaching it from its parent and freeing allocated memory.
 
static unlang_action_t unlang_subrequest_init (rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 Allocates a new subrequest and initialises it.
 
int unlang_subrequest_op_init (void)
 Initialise subrequest ops.
 
static unlang_action_t unlang_subrequest_parent_resume (rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 Parent being resumed after a child completes.
 
static void unlang_subrequest_signal (UNUSED request_t *request, unlang_stack_frame_t *frame, fr_signal_t action)
 Send a signal from parent request to subrequest.
 

Detailed Description

Unlang "subrequest" and "detach" keyword evaluation.

Id
06fb3ba4fa974b3569dfec812b2b9494c65490ef

Definition in file subrequest.c.

Function Documentation

◆ unlang_subrequest_alloc()

request_t * unlang_subrequest_alloc ( request_t parent,
fr_dict_t const *  namespace 
)

Allocate a subrequest to run through a virtual server at some point in the future.

Parameters
[in]parentto hang sub request off of.
[in]namespacethe child will operate in.
Returns
  • A new child request.
  • NULL on failure.

Definition at line 303 of file subrequest.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 request_t request,
unlang_stack_frame_t frame 
)
static

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

Note
Only executes if unlang_subrequest_child_push was called, not with the normal subrequest keyword.

Definition at line 313 of file subrequest.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 ( request_t child,
rlm_rcode_t p_result,
void const *  unique_session_ptr,
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]p_resultWhere to write the result of the subrequest.
[in]childto push.
[in]unique_session_ptrUnique identifier for child's session data.
[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 422 of file subrequest.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)

Add a child request to the runnable queue.

Parameters
[in]requestto add to the runnable queue.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 496 of file subrequest.c.

+ Here is the call 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, or manually 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.

Note
Called from the parent to start a child running.

Definition at line 351 of file subrequest.c.

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

◆ unlang_subrequest_detach_and_free()

void unlang_subrequest_detach_and_free ( request_t **  child)

Free a child request, detaching it from its parent and freeing allocated memory.

Parameters
[in]childto free.

Definition at line 288 of file subrequest.c.

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

◆ unlang_subrequest_init()

static unlang_action_t unlang_subrequest_init ( rlm_rcode_t p_result,
request_t request,
unlang_stack_frame_t frame 
)
static

Allocates a new subrequest and initialises it.

Definition at line 166 of file subrequest.c.

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

◆ unlang_subrequest_op_init()

int unlang_subrequest_op_init ( void  )

Initialise subrequest ops.

Definition at line 516 of file subrequest.c.

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

◆ unlang_subrequest_parent_resume()

static unlang_action_t unlang_subrequest_parent_resume ( rlm_rcode_t p_result,
request_t request,
unlang_stack_frame_t frame 
)
static

Parent being resumed after a child completes.

Definition at line 97 of file subrequest.c.

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

◆ unlang_subrequest_signal()

static void unlang_subrequest_signal ( UNUSED request_t request,
unlang_stack_frame_t frame,
fr_signal_t  action 
)
static

Send a signal from parent request to subrequest.

Definition at line 40 of file subrequest.c.

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