Skip to content
Permalink
Browse files

make UNLANG_TYPE_CALL skip using using resumable frames

and now that nothing uses resumable frames, remove them entirely
from the interpreter
  • Loading branch information
alandekok committed Sep 29, 2019
1 parent 9d7bdf0 commit 9ed18863b7467bb475eb81bf22030e15a6b04451
Showing with 47 additions and 312 deletions.
  1. +32 −85 src/lib/unlang/call.c
  2. +13 −159 src/lib/unlang/interpret.c
  3. +0 −13 src/lib/unlang/interpret.h
  4. +2 −4 src/lib/unlang/module.c
  5. +0 −51 src/lib/unlang/unlang_priv.h
@@ -38,60 +38,46 @@ static void unlang_call_signal(UNUSED REQUEST *request, void *ctx, fr_state_sign
}


/** Resume a subrequest in another virtual server.
*
*/
static unlang_action_t unlang_call_resume(REQUEST *request, rlm_rcode_t *presult, void *rctx)
static unlang_action_t unlang_call_run(REQUEST *request, rlm_rcode_t *presult)
{
REQUEST *child = talloc_get_type_abort(rctx, REQUEST);
unlang_stack_t *stack = request->stack;
unlang_stack_frame_t *frame = &stack->frame[stack->depth];
unlang_t *instruction = frame->instruction->parent;
REQUEST *child = frame->state;
rlm_rcode_t rcode;
#ifndef NDEBUG
unlang_resume_t *mr;
#endif

/*
* Continue running the child.
* Run the *child* through the "call" section, as a way
* to get post-processing of the packet.
*/
rcode = unlang_interpret_run(child);
if (rcode == RLM_MODULE_YIELD) {
#ifndef NDEBUG
rad_assert(frame->instruction->type == UNLANG_TYPE_RESUME);

mr = unlang_generic_to_resume(frame->instruction);
(void) talloc_get_type_abort(mr, unlang_resume_t);

rad_assert(mr->resume == NULL);
#endif
if (rcode == RLM_MODULE_YIELD) return UNLANG_ACTION_YIELD;

/*
* If the child yields, our current frame is still an
* unlang_resume_t.
*/
return UNLANG_ACTION_YIELD;
}

stack = child->stack;
if (stack->depth > 0) {
rcode = unlang_interpret_run(child);
if (rcode == RLM_MODULE_YIELD) {
return UNLANG_ACTION_YIELD;
}
}

rad_assert(frame->instruction->type == UNLANG_TYPE_RESUME);
fr_state_store_in_parent(child, frame->instruction, 0);
unlang_subrequest_free(&child);

*presult = rcode;
return UNLANG_ACTION_CALCULATE_RESULT;
}

frame->instruction->type = UNLANG_TYPE_SUBREQUEST; /* for debug purposes */
static unlang_action_t unlang_call_process(REQUEST *request, rlm_rcode_t *presult)
{
unlang_stack_t *stack = request->stack;
unlang_stack_frame_t *frame = &stack->frame[stack->depth];
REQUEST *child = frame->state;
rlm_rcode_t rcode;

fr_state_store_in_parent(child, instruction, 0);
unlang_subrequest_free(&child);
/*
* @todo - we can't change packet types
* (e.g. Access-Request -> Accounting-Request) unless
* we're in a subrequest.
*/
rcode = child->async->process(child->async->process_inst, child);
if (rcode == RLM_MODULE_YIELD) {
return UNLANG_ACTION_YIELD;
}

*presult = rcode;
return UNLANG_ACTION_CALCULATE_RESULT;
frame->process = unlang_call_run;
return unlang_call_run(request, presult);
}

static unlang_action_t unlang_call(REQUEST *request, rlm_rcode_t *presult)
@@ -101,9 +87,6 @@ static unlang_action_t unlang_call(REQUEST *request, rlm_rcode_t *presult)
unlang_t *instruction = frame->instruction;
REQUEST *child;

rlm_rcode_t rcode;
unlang_resume_t *mr;

unlang_group_t *g;

char const *server;
@@ -113,7 +96,6 @@ static unlang_action_t unlang_call(REQUEST *request, rlm_rcode_t *presult)

fr_io_process_t *process_p;
void *process_inst;
rlm_rcode_t final;

g = unlang_generic_to_group(instruction);
rad_assert(g->children != NULL);
@@ -122,8 +104,8 @@ static unlang_action_t unlang_call(REQUEST *request, rlm_rcode_t *presult)

/*
* Check for loops. We do this by checking the source of
* the call statement. If any parent is doing the same
* call as we are, then it's a loop.
* the call statement. If any parent is making a call
* from the same place as this one, then we're in a loop.
*/
for (child = request->parent;
child != NULL;
@@ -190,10 +172,7 @@ static unlang_action_t unlang_call(REQUEST *request, rlm_rcode_t *presult)

child = unlang_io_subrequest_alloc(request, dict, UNLANG_NORMAL_CHILD);
if (!child) {
rcode = RLM_MODULE_FAIL;

calculate_result:
*presult = rcode;
*presult = RLM_MODULE_FAIL;
return UNLANG_ACTION_CALCULATE_RESULT;
}

@@ -241,40 +220,9 @@ static unlang_action_t unlang_call(REQUEST *request, rlm_rcode_t *presult)
*/
unlang_interpret_push(child, g->children, frame->result,
UNLANG_NEXT_SIBLING, UNLANG_TOP_FRAME);

/*
* @todo - we can't change packet types
* (e.g. Access-Request -> Accounting-Request) unless
* we're in a subrequest.
*/
final = child->async->process(child->async->process_inst, child);
if (final == RLM_MODULE_YIELD) {
yield:
/*
* Create the "resume" stack frame, and have it replace our stack frame.
*/
mr = unlang_interpret_resume_alloc(request, NULL, NULL, child);
if (!mr) {
rcode = RLM_MODULE_FAIL;
goto calculate_result;
}

*presult = RLM_MODULE_YIELD;
return UNLANG_ACTION_YIELD;
}

/*
* Run the *child* through the "call" section, as a way
* to get post-processing of the packet.
*/
rcode = unlang_interpret_run(child);
if (rcode == RLM_MODULE_YIELD) goto yield;

fr_state_store_in_parent(child, instruction, 0);
unlang_subrequest_free(&child);

*presult = rcode;
return UNLANG_ACTION_CALCULATE_RESULT;
frame->process = unlang_call_process;
frame->state = child;
return unlang_call_process(request, presult);
}


@@ -285,7 +233,6 @@ void unlang_call_init(void)
.name = "call",
.func = unlang_call,
.signal = unlang_call_signal,
.resume = unlang_call_resume,
.debug_braces = true
});
}

0 comments on commit 9ed1886

Please sign in to comment.
You can’t perform that action at this time.