Skip to content
Permalink
Browse files

add process / signal to the unlang stack frame

so that the process functions can set / reset them as necessary
which then means that we can get rid of the repeat / resume
handling.  And just use the "process" functions
  • Loading branch information
alandekok committed Sep 25, 2019
1 parent e932653 commit 58ac05df4cbc1670c5df7fdb8c0ce8d113489889
Showing with 21 additions and 2 deletions.
  1. +18 −2 src/lib/unlang/interpret.c
  2. +3 −0 src/lib/unlang/unlang_priv.h
@@ -158,6 +158,8 @@ unlang_resume_t *unlang_interpret_resume_alloc(REQUEST *request, void *resume, v
* Replaces the current stack frame with a RESUME frame.
*/
frame->instruction = unlang_resume_to_generic(mr);
frame->process = unlang_ops[frame->instruction->type].func;
frame->signal = unlang_ops[frame->instruction->type].signal;
repeatable_set(frame);

return mr;
@@ -260,6 +262,15 @@ void unlang_interpret_push(REQUEST *request, unlang_t *instruction,
frame->uflags = UNWIND_FLAG_NONE;
if (top_frame) top_frame_set(frame);
frame->instruction = instruction;

/*
* There's no instruction for the top frame.
*/
if (instruction) {
frame->process = unlang_ops[instruction->type].func;
frame->signal = unlang_ops[instruction->type].signal;
}

frame->result = default_rcode;
frame->priority = -1;
frame->state = NULL;
@@ -411,7 +422,11 @@ static inline void frame_next(unlang_stack_frame_t *frame)
{
frame_cleanup(frame);
frame->instruction = frame->next;
if (frame->instruction) frame->next = frame->instruction->next;
if (frame->instruction) {
frame->process = unlang_ops[frame->instruction->type].func;
frame->signal = unlang_ops[frame->instruction->type].signal;
frame->next = frame->instruction->next;
}
}

/** Pop a stack frame, removing any associated dynamically allocated state
@@ -507,7 +522,8 @@ static inline unlang_frame_action_t frame_eval(REQUEST *request, unlang_stack_fr
RDEBUG4("** [%i] %s >> %s", stack->depth, __FUNCTION__,
unlang_ops[instruction->type].name);

action = unlang_ops[instruction->type].func(request, result, priority);
rad_assert(frame->process != NULL);
action = frame->process(request, result, priority);

RDEBUG4("** [%i] %s << %s (%d)", stack->depth, __FUNCTION__,
fr_table_str_by_value(unlang_action_table, action, "<INVALID>"), *priority);
@@ -250,6 +250,9 @@ typedef struct {
unlang_t *instruction; //!< The unlang node we're evaluating.
unlang_t *next; //!< The next unlang node we will evaluate

unlang_op_call_t process; //!< function to call for processing this stack frame
unlang_op_signal_t signal; //!< function to call when signalling this stack frame

/** Stack frame specialisations
*
* These store extra (mutable) state data, for the immutable (#unlang_t)

0 comments on commit 58ac05d

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