From: Arran Cudbard-Bell Date: Fri, 25 Nov 2016 23:58:39 +0000 (-0500) Subject: Expose the worker's event list X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f62abb286eb9cb0aa98e7cf3b9caccf9615d1fc;p=thirdparty%2Ffreeradius-server.git Expose the worker's event list --- diff --git a/src/include/radiusd.h b/src/include/radiusd.h index 14863747f29..16ccf295081 100644 --- a/src/include/radiusd.h +++ b/src/include/radiusd.h @@ -574,9 +574,10 @@ int radius_copy_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, char con #define pair_make_config(_a, _b, _c) fr_pair_make(request, &request->control, _a, _b, _c) /* threads.c */ -int thread_pool_bootstrap(CONF_SECTION *cs, bool *spawn_workers); -int thread_pool_init(void); -void thread_pool_stop(void); +fr_event_list_t *thread_event_list(void); +int thread_pool_bootstrap(CONF_SECTION *cs, bool *spawn_workers); +int thread_pool_init(void); +void thread_pool_stop(void); /* * In threads.c diff --git a/src/include/threads.h b/src/include/threads.h index 1de4c0cabf6..8076fe12da4 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -37,7 +37,7 @@ typedef void (*pthread_destructor_t)(void*); * These should ONLY be called where __Thread_local is a pointer to heap * allocated memory that needs to be freed on thread exit. * - * For other types like ints __Thread_local should be used directly + * For other types like ints _Thread_local should be used directly * without the macros. */ #ifndef HAVE_PTHREAD_H diff --git a/src/main/threads.c b/src/main/threads.c index 2b85c20bab2..69b03bdab61 100644 --- a/src/main/threads.c +++ b/src/main/threads.c @@ -97,6 +97,15 @@ typedef struct fr_pps_t { } fr_pps_t; #endif +/** Holds this thread's event_list + * + * Some modules need direct access to the event_list, so they can + * insert events that fire independently of processing requests. + * + * Libcurl is a good example of this, where it manages its own timers + * for IO events, and needs to be awoken, when a timeout expires. + */ +static _Thread_local fr_event_list_t *el; /* * A data structure to manage the thread pool. There's no real @@ -437,6 +446,18 @@ static void thread_process_request(THREAD_HANDLE *thread, REQUEST *request) #endif } +/** Return this thread's event list + * + * Can be used by modules to get the event_list for the current thread, + * so that they can add their own timers outside of request processing. + * + * @return This thread's fr_event_list_t. + */ +fr_event_list_t *thread_event_list(void) +{ + return el; +} + /* * The main thread handler for requests. * @@ -447,7 +468,6 @@ static void *thread_handler(void *arg) int rcode; THREAD_HANDLE *thread = talloc_get_type_abort(arg, THREAD_HANDLE); TALLOC_CTX *ctx; - fr_event_list_t *el; fr_heap_t *local_backlog; #ifdef HAVE_GPERFTOOLS_PROFILER_H