From: Alan T. DeKok Date: Mon, 14 Nov 2022 21:40:56 +0000 (-0500) Subject: add unlang_thread_instance() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78f92d73a613def160a20ac3f3a07255d25d3bac;p=thirdparty%2Ffreeradius-server.git add unlang_thread_instance() which for now is only called from the "limit" keyword. The thread instance data could arguably go into the stack frame, but 99.9% of the stack frames won't use it. So for now we just make the users call it manually --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 134d1256c6a..aa896c7e705 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -4586,6 +4586,20 @@ int unlang_thread_instantiate(TALLOC_CTX *ctx) return 0; } +/** Get the thread-instance data for an instruction. + * + * @param[in] instruction the instruction to use + * @return a pointer to thread-local data + */ +void *unlang_thread_instance(unlang_t const *instruction) +{ + if (!instruction->number || !unlang_thread_array) return NULL; + + fr_assert(instruction->number <= unlang_number); + + return unlang_thread_array[instruction->number].thread_inst; +} + #ifdef WITH_PERF void unlang_frame_perf_init(unlang_stack_frame_t *frame) { diff --git a/src/lib/unlang/unlang_priv.h b/src/lib/unlang/unlang_priv.h index 3fc80d026bb..80401aacecf 100644 --- a/src/lib/unlang/unlang_priv.h +++ b/src/lib/unlang/unlang_priv.h @@ -237,6 +237,8 @@ typedef struct { #endif } unlang_thread_t; +void *unlang_thread_instance(unlang_t const *instruction); + #ifdef WITH_PERF void unlang_frame_perf_init(unlang_stack_frame_t *frame); void unlang_frame_perf_yield(unlang_stack_frame_t *frame);