]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Cancelling and unwinding are now really separate things
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 6 May 2025 23:04:49 +0000 (17:04 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 7 May 2025 00:53:01 +0000 (18:53 -0600)
src/lib/unlang/interpret.c
src/lib/unlang/timeout.c
src/lib/unlang/unlang_priv.h

index 2f2fc158a3007428a9f979d00f149f77c6123550..7f72d6c242bc44d5357acd357b9910687cce8f41 100644 (file)
@@ -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, "<invalid>"),
                *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);
                }
        }
index fb7b10cca780648b81c4e55256d497d500eb8a5e..3274fe96691aecaad188d50193ff497c7e365ff2 100644 (file)
@@ -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);
index a25f3439b4b30f8e5763aaf20c24c51fb33b099f..4fafd7924d766b4d3d715c2f09ae7f6e85adc2e7 100644 (file)
@@ -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);
        }