* Stores module and thread specific data.
*/
typedef struct {
+ void *data; //!< Thread specific instance data.
+
fr_event_list_t *el; //!< Event list associated with this thread.
+ rad_module_t const *module; //!< Public module structure. Cached for convenience,
+ ///< and to prevent use-after-free if the global data
+ ///< is freed before the thread instance data.
+
void *mod_inst; //!< Avoids thread_inst->inst->dl_inst->data.
///< This is in the hot path, so it makes sense.
- module_instance_t *inst; //!< Non-thread local instance of this
-
- void *data; //!< Thread specific instance data.
-
uint64_t total_calls; //! total number of times we've been called
uint64_t active_callers; //! number of active callers. i.e. number of current yields
} module_thread_instance_t;
{
module_thread_instance_t *ti = talloc_get_type_abort(to_free, module_thread_instance_t);
- if (ti->inst->module->thread_detach) {
- (void) ti->inst->module->thread_detach(ti->el, ti->data);
+ if (ti->module->thread_detach) {
+ (void) ti->module->thread_detach(ti->el, ti->data);
}
talloc_free(ti);
MEM(ti = talloc_zero(NULL, module_thread_instance_t));
ti->el = thread_inst_ctx->el;
- ti->inst = mi;
+ ti->module = mi->module;
ti->mod_inst = mi->dl_inst->data; /* For efficient lookups */
if (mi->module->thread_inst_size) {