]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
return module_thread_instance_t, so we can access counters
authorAlan T. DeKok <aland@freeradius.org>
Wed, 19 Apr 2017 15:25:59 +0000 (11:25 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 19 Apr 2017 15:27:31 +0000 (11:27 -0400)
src/include/interpreter.h
src/main/modules.c
src/main/unlang_interpret.c

index 72e1d1fde386315bceaa6abef5f48b8c1bab368d..ec1175c1290383ad62de8c9d76784786dd10ca73 100644 (file)
@@ -162,7 +162,7 @@ typedef struct {
  */
 typedef struct {
        unlang_module_call_t    module;         //!< Module call that returned #RLM_MODULE_YIELD.
-       void                    *thread;        //!< data specific to the module.
+       module_thread_instance_t *thread;       //!< thread-local data for this module
        fr_unlang_resume_t      callback;       //!< Function the yielding module indicated should
                                                //!< be called when the request could be resumed.
        fr_unlang_action_t      action_callback;  //!< Function the yielding module indicated should
@@ -182,7 +182,7 @@ typedef struct {
 } unlang_xlat_inline_t;
 
 typedef struct {
-       void                    *thread;        //!< Thread specific module instance.
+       module_thread_instance_t *thread;       //!< thread-local data for this module
 } unlang_stack_entry_modcall_t;
 
 /** State of a foreach loop
index 1ab2f67832b4e6add50c6adfacb4a10857b18113..4b082f11e7dc4130c90fe1c9e6652e075bab5e57 100644 (file)
@@ -489,17 +489,12 @@ void *module_thread_instance_find(void *instance)
 {
        module_instance_t               *inst = instance;
        rbtree_t                        *tree = module_thread_inst_tree;
-       module_thread_instance_t        find, *found;
-
-       if (!inst->module->thread_instantiate || !inst->module->thread_inst_size) return NULL;
+       module_thread_instance_t        find;
 
        memset(&find, 0, sizeof(find));
        find.inst = inst;
 
-       found = rbtree_finddata(tree, &find);
-       if (!found) return NULL;
-
-       return found->data;
+       return rbtree_finddata(tree, &find);
 }
 
 /** Destructor for module_thread_instance_t
index 78b5cee2754f53ac6a03b61421af531e1313dabb..5ffafbeee5b11c0dac210194d21e5adac8ef85ec 100644 (file)
@@ -703,6 +703,7 @@ static unlang_action_t unlang_module_call(REQUEST *request, unlang_stack_t *stac
         *      Grab the thread/module specific data if any exists.
         */
        frame->modcall.thread = module_thread_instance_find(sp->module_instance);
+       rad_assert(frame->modcall.thread != NULL);
 
        /*
         *      For logging unresponsive children.
@@ -710,7 +711,7 @@ static unlang_action_t unlang_module_call(REQUEST *request, unlang_stack_t *stac
        request->module = sp->module_instance->name;
 
        safe_lock(sp->module_instance);
-       request->rcode = sp->method(sp->module_instance->data, frame->modcall.thread, request);
+       request->rcode = sp->method(sp->module_instance->data, frame->modcall.thread->data, request);
        safe_unlock(sp->module_instance);
 
        request->module = NULL;
@@ -850,7 +851,7 @@ static unlang_action_t unlang_resumption(REQUEST *request, unlang_stack_t *stack
        memcpy(&mutable, &mr->ctx, sizeof(mutable));
 
        safe_lock(sp->module_instance);
-       *presult = mr->callback(request, mr->module.module_instance->data, mr->thread, mutable);
+       *presult = mr->callback(request, mr->module.module_instance->data, mr->thread->data, mutable);
        safe_unlock(sp->module_instance);
 
        RDEBUG2("%s (%s)", instruction->name ? instruction->name : "",