*/
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
} 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
{
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
* 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.
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;
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 : "",