return;
}
- (void)unlang_interpret(request);
+ (void)unlang_interpret(request, UNLANG_REQUEST_RESUME);
now = fr_time();
}
*
* @param[in] request to run. If this is an internal request
* the request may be freed by the interpreter.
+ * @param[in] running Is the interpreter already running.
* @return The final request rcode.
*/
-CC_HINT(hot) rlm_rcode_t unlang_interpret(request_t *request)
+CC_HINT(hot) rlm_rcode_t unlang_interpret(request_t *request, bool running)
{
unlang_frame_action_t fa = UNLANG_FRAME_ACTION_NEXT;
rlm_rcode_t rcode;
fr_assert_msg(intp, "request has no interpreter associated");
RDEBUG4("** [%i] %s - interpret entered", stack->depth, __FUNCTION__);
- intp->funcs.resume(request, intp->uctx);
+ if (!running) intp->funcs.resume(request, intp->uctx);
for (;;) {
fr_assert(request->master_state != REQUEST_STOP_PROCESSING);
continue;
case UNLANG_FRAME_ACTION_YIELD:
+ /* Cannot yield from a nested call to unlang_interpret */
+ fr_assert(!running);
+
RDEBUG4("** [%i] %s - interpret yielding", stack->depth, __FUNCTION__);
intp->funcs.yield(request, intp->uctx);
return stack->result;
#define UNLANG_STACK_MAX (64) //!< The maximum depth of the stack.
#define UNLANG_FRAME_PRE_ALLOC (128) //!< How much memory we pre-alloc for each frame.
+#define UNLANG_REQUEST_RUNNING (true)
+#define UNLANG_REQUEST_RESUME (false)
+
/** Interpreter handle
*
*/
unlang_interpret_t *unlang_interpret_get_thread_default(void);
-rlm_rcode_t unlang_interpret(request_t *request) CC_HINT(hot);
+rlm_rcode_t unlang_interpret(request_t *request, bool running) CC_HINT(hot);
rlm_rcode_t unlang_interpret_synchronous(fr_event_list_t *el, request_t *request);
el = intps->el;
- rcode = unlang_interpret(request);
+ rcode = unlang_interpret(request, UNLANG_REQUEST_RESUME);
while ((dont_wait_for_event = (fr_heap_num_elements(intps->runnable) > 0)) ||
(intps->yielded > 0)) {
* do another loop around.
*/
RDEBUG4(">>> interpreter (iteration %i)", ++iterations);
- sub_rcode = unlang_interpret(sub_request);
+ sub_rcode = unlang_interpret(sub_request, UNLANG_REQUEST_RESUME);
RDEBUG4("<<< interpreter (iteration %i) - %s", iterations,
fr_table_str_by_value(rcode_table, sub_rcode, "<INVALID>"));
if (unlang_xlat_push(ctx, &success, out, request, xlat, UNLANG_TOP_FRAME) < 0) return -1;
- (void) unlang_interpret(request);
+ (void) unlang_interpret(request, UNLANG_REQUEST_RUNNING);
if (!success) return -1;