From: Arran Cudbard-Bell Date: Tue, 5 Mar 2024 16:37:52 +0000 (-0600) Subject: Have cancel xlat execute immediately when timeout value is zero X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca9d31ce606915a196cefa190c425242fb0daffa;p=thirdparty%2Ffreeradius-server.git Have cancel xlat execute immediately when timeout value is zero --- diff --git a/src/lib/unlang/interpret.c b/src/lib/unlang/interpret.c index d330a71aa1e..7674008a966 100644 --- a/src/lib/unlang/interpret.c +++ b/src/lib/unlang/interpret.c @@ -27,6 +27,8 @@ RCSID("$Id$") #include #include #include +#include +#include #include "interpret_priv.h" #include "module_priv.h" @@ -1435,6 +1437,9 @@ static xlat_action_t unlang_cancel_never_run(UNUSED TALLOC_CTX *ctx, UNUSED fr_d /** Allows a request to dynamically alter its own lifetime * + * %cancel() + * + * If timeout is 0, then the request is immediately cancelled. */ static xlat_action_t unlang_cancel_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, @@ -1485,7 +1490,9 @@ static xlat_action_t unlang_cancel_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, * We call unlang_xlat_yield to keep the interpreter happy * as it expects to see a resume function set. */ - if (!timeout) return unlang_xlat_yield(request, unlang_cancel_never_run, NULL, 0, NULL); + if (!timeout || fr_time_delta_eq(timeout->vb_time_delta, fr_time_delta_from_sec(0))) { + return unlang_xlat_yield(request, unlang_cancel_never_run, NULL, 0, NULL); + } if (ev_p_og) { MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_TIME_DELTA, NULL));