]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add unlang_thread_instance()
authorAlan T. DeKok <aland@freeradius.org>
Mon, 14 Nov 2022 21:40:56 +0000 (16:40 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 14 Nov 2022 21:48:47 +0000 (16:48 -0500)
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

src/lib/unlang/compile.c
src/lib/unlang/unlang_priv.h

index 134d1256c6aecc700527f347bacba1d16d6c470a..aa896c7e7053d04534579df4834f2bbf43381e8d 100644 (file)
@@ -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)
 {
index 3fc80d026bbdb291ab5e4c9f89a04db05eb4b5f1..80401aacecff011472fbd34927194e3e79e63b2c 100644 (file)
@@ -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);