From: Arran Cudbard-Bell Date: Tue, 6 May 2025 23:04:49 +0000 (-0600) Subject: Cancelling and unwinding are now really separate things X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecfac431025026ddd7c73c7d36b037d36be0c63e;p=thirdparty%2Ffreeradius-server.git Cancelling and unwinding are now really separate things --- diff --git a/src/lib/unlang/interpret.c b/src/lib/unlang/interpret.c index 2f2fc158a30..7f72d6c242b 100644 --- a/src/lib/unlang/interpret.c +++ b/src/lib/unlang/interpret.c @@ -89,7 +89,7 @@ static void frame_dump(request_t *request, unlang_stack_frame_t *frame) RDEBUG2("top_frame %s", is_top_frame(frame) ? "yes" : "no"); RDEBUG2("repeat %s", is_repeatable(frame) ? "yes" : "no"); RDEBUG2("resumable %s", is_yielded(frame) ? "yes" : "no"); - RDEBUG2("cancelled %s", is_cancelled(frame) ? "yes" : "no"); + RDEBUG2("unwind %s", is_unwinding(frame) ? "yes" : "no"); if (frame->instruction) { RDEBUG2("control %s%s%s", @@ -311,7 +311,7 @@ unlang_frame_action_t result_calculate(request_t *request, unlang_stack_frame_t fr_table_str_by_value(mod_rcode_table, *result, ""), *priority); - if (is_cancelled(frame)) { + if (is_unwinding(frame)) { RDEBUG4("** [%i] %s - frame is cancelled", stack->depth, __FUNCTION__); frame->result = *result; @@ -585,7 +585,7 @@ unlang_frame_action_t frame_eval(request_t *request, unlang_stack_frame_t *frame * asynchronously, and the process function * may not be aware that it's happened. */ - if (is_cancelled(frame)) goto calculate_result; + if (is_unwinding(frame)) goto calculate_result; switch (ua) { case UNLANG_ACTION_STOP_PROCESSING: @@ -778,7 +778,7 @@ CC_HINT(hot) rlm_rcode_t unlang_interpret(request_t *request, bool running) * back on up the stack. */ - if (!is_cancelled(frame) && is_repeatable(frame)) { + if (!is_unwinding(frame) && is_repeatable(frame)) { fa = UNLANG_FRAME_ACTION_NEXT; continue; } @@ -1181,7 +1181,7 @@ void unlang_interpret_signal(request_t *request, fr_signal_t action) * it's not cancellable, and we need to let the * request progress normally. */ - if (stack && is_yielded(frame) && is_cancelled(frame) && !unlang_request_is_scheduled(request)) { + if (stack && is_yielded(frame) && is_unwinding(frame) && !unlang_request_is_scheduled(request)) { unlang_interpret_mark_runnable(request); } } diff --git a/src/lib/unlang/timeout.c b/src/lib/unlang/timeout.c index fb7b10cca78..3274fe96691 100644 --- a/src/lib/unlang/timeout.c +++ b/src/lib/unlang/timeout.c @@ -87,7 +87,7 @@ static void unlang_timeout_handler(UNUSED fr_timer_list_t *tl, UNUSED fr_time_t * something else will run it to completion, and mark * the request as complete. */ - if (is_yielded(frame) && is_cancelled(frame)) unlang_interpret_mark_runnable(request); + if (is_yielded(frame) && is_unwinding(frame)) unlang_interpret_mark_runnable(request); state->fired = true; RINDENT_RESTORE(request, state); diff --git a/src/lib/unlang/unlang_priv.h b/src/lib/unlang/unlang_priv.h index a25f3439b4b..4fafd7924d7 100644 --- a/src/lib/unlang/unlang_priv.h +++ b/src/lib/unlang/unlang_priv.h @@ -106,7 +106,7 @@ typedef enum CC_HINT(flag_enum) { ///< interpreting and return, control then passes ///< to whatever called the interpreter. UNLANG_FRAME_FLAG_YIELDED = 0x04, //!< frame has yielded - UNLANG_FRAME_FLAG_CANCEL = 0x08, //!< This frame has been marked up for cancellation. + UNLANG_FRAME_FLAG_UNWIND = 0x08, //!< This frame should be unwound without evaluation. } unlang_frame_flag_t; DIAG_ON(attributes) @@ -366,17 +366,17 @@ extern size_t mod_rcode_table_len; static inline void repeatable_set(unlang_stack_frame_t *frame) { frame->flag |= UNLANG_FRAME_FLAG_REPEAT; } static inline void top_frame_set(unlang_stack_frame_t *frame) { frame->flag |= UNLANG_FRAME_FLAG_TOP_FRAME; } static inline void yielded_set(unlang_stack_frame_t *frame) { frame->flag |= UNLANG_FRAME_FLAG_YIELDED; } -static inline void cancel_set(unlang_stack_frame_t *frame) { frame->flag |= UNLANG_FRAME_FLAG_CANCEL; } +static inline void unwind_set(unlang_stack_frame_t *frame) { frame->flag |= UNLANG_FRAME_FLAG_UNWIND; } static inline void repeatable_clear(unlang_stack_frame_t *frame) { frame->flag &= ~UNLANG_FRAME_FLAG_REPEAT; } static inline void top_frame_clear(unlang_stack_frame_t *frame) { frame->flag &= ~UNLANG_FRAME_FLAG_TOP_FRAME; } static inline void yielded_clear(unlang_stack_frame_t *frame) { frame->flag &= ~UNLANG_FRAME_FLAG_YIELDED; } -static inline void cancel_clear(unlang_stack_frame_t *frame) { frame->flag &= ~UNLANG_FRAME_FLAG_CANCEL; } +static inline void unwind_clear(unlang_stack_frame_t *frame) { frame->flag &= ~UNLANG_FRAME_FLAG_UNWIND; } static inline bool is_repeatable(unlang_stack_frame_t const *frame) { return frame->flag & UNLANG_FRAME_FLAG_REPEAT; } static inline bool is_top_frame(unlang_stack_frame_t const *frame) { return frame->flag & UNLANG_FRAME_FLAG_TOP_FRAME; } static inline bool is_yielded(unlang_stack_frame_t const *frame) { return frame->flag & UNLANG_FRAME_FLAG_YIELDED; } -static inline bool is_cancelled(unlang_stack_frame_t const *frame) { return frame->flag & UNLANG_FRAME_FLAG_CANCEL; } +static inline bool is_unwinding(unlang_stack_frame_t const *frame) { return frame->flag & UNLANG_FRAME_FLAG_UNWIND; } static inline bool _instruction_has_debug_braces(unlang_t const *instruction) { return unlang_ops[instruction->type].flag & UNLANG_OP_FLAG_DEBUG_BRACES; } static inline bool _frame_has_debug_braces(unlang_stack_frame_t const *frame) { return unlang_ops[frame->instruction->type].flag & UNLANG_OP_FLAG_DEBUG_BRACES; } @@ -449,7 +449,7 @@ static inline unlang_action_t unwind_to_depth(unlang_stack_t *stack, unsigned in for (i = depth; i >= to_depth; i--) { frame = &stack->frame[i]; if (!is_cancellable(frame)) continue; - frame->flag |= UNLANG_FRAME_FLAG_CANCEL; + unwind_set(frame); } return UNLANG_ACTION_CALCULATE_RESULT; @@ -595,7 +595,7 @@ static inline void frame_pop(request_t *request, unlang_stack_t *stack) * If the frame was cancelled, the signal function will * have already been called. */ - if (!is_cancelled(frame) && is_repeatable(frame)) { + if (!is_unwinding(frame) && is_repeatable(frame)) { if (frame->signal) frame->signal(request, frame, FR_SIGNAL_CANCEL); repeatable_clear(frame); }