]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add unlang_interpret_is_resumable() and use it in worker.c
authorAlan T. DeKok <aland@freeradius.org>
Mon, 14 Dec 2020 18:32:16 +0000 (13:32 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 14 Dec 2020 18:33:17 +0000 (13:33 -0500)
so that we can IMMEDIATELY tell if we have logic errors, as was
fixed in the previous commit.  Otherwise time spent debugging is
time wasted.

src/lib/io/worker.c
src/lib/unlang/interpret.c
src/lib/unlang/interpret.h

index 937b89efa2b8feec6f0c74400c610e6e147f60d2..62893d5baf1860fb00ca0d92a2240aacc2545eb9 100644 (file)
@@ -936,6 +936,20 @@ redo:
                break;
        }
 
+       /*
+        *      If we're running a real request, then the final
+        *      indentation MUST be zero.  Otherwise we skipped
+        *      something!
+        *
+        *      Also check that the request is NOT marked as
+        *      "yielded", but is in fact done.
+        *
+        *      @todo - check that the stack is at frame 0, otherwise
+        *      more things have gone wrong.
+        */
+       fr_assert(request->parent || (request->log.unlang_indent == 0));
+       fr_assert(!unlang_interpret_is_resumable(request));
+
        RDEBUG("Done request");
 
        /*
index 63b52a27f7c2c1298f2c45dbff1cf5388db61450..2b87a2881e8126bf2276d5fd42e48b1bb9c2d340 100644 (file)
@@ -1159,6 +1159,21 @@ rlm_rcode_t unlang_interpret_stack_result(request_t *request)
        return stack->result;
 }
 
+/** Check if a request as resumable.
+ *
+ * @param[in] request          The current request.
+ * @return
+ *     - true if the request is resumable (i.e. has yeilded)
+ *     - false if the request is not resumable (i.e. has not yielded)
+ */
+bool unlang_interpret_is_resumable(request_t *request)
+{
+       unlang_stack_t                  *stack = request->stack;
+       unlang_stack_frame_t            *frame = &stack->frame[stack->depth];
+
+       return is_yielded(frame);
+}
+
 /** Mark a request as resumable.
  *
  * It's not called "unlang_interpret", because it doesn't actually
index 043c3af4c8ab297ebd39bf3e80c91f2c1d8fcc09..2fd8f3152ed6d488fa694b22b2a551ece84b14e3 100644 (file)
@@ -116,6 +116,8 @@ void                *unlang_interpret_stack_alloc(TALLOC_CTX *ctx);
 
 void           unlang_interpret_mark_resumable(request_t *request);
 
+bool           unlang_interpret_is_resumable(request_t *request);
+
 void           unlang_interpret_signal(request_t *request, fr_state_signal_t action);
 
 int            unlang_interpret_stack_depth(request_t *request);