]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Expose the worker's event list
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 25 Nov 2016 23:58:39 +0000 (18:58 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 26 Nov 2016 15:23:29 +0000 (10:23 -0500)
src/include/radiusd.h
src/include/threads.h
src/main/threads.c

index 14863747f29076d352455ce7f267b0b73e9f7b32..16ccf295081e16cc0bd71206d603e014e5347894 100644 (file)
@@ -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
index 1de4c0cabf6b5134ba63c382e3160b92aa6a52fc..8076fe12da423816e1490dd75b04c0dc716d7901 100644 (file)
@@ -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
index 2b85c20bab214d81217b9659e8defc42c7cd485e..69b03bdab61c03b34591948cec4ffd3e0184109a 100644 (file)
@@ -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