static dl_module_loader_t *dl_module_loader;
+/** Make data to instance name resolution more efficient
+ *
+ */
+typedef struct {
+ void *data; //!< Module's data.
+ dl_module_inst_t *inst; //!< Instance wrapper struct.
+} dl_module_inst_cache_t;
+
+static _Thread_local dl_module_inst_cache_t dl_inst_cache;
+
/** Modules which need RTLD_GLOBAL set
*
*/
memcpy(&mutable, &data, sizeof(mutable));
+ if (dl_inst_cache.data == data) return dl_inst_cache.inst;
+
return rbtree_finddata(dl_module_loader->inst_data_tree, &(dl_module_inst_t){ .data = mutable });
}
+/** Lookup instance name via instance data
+ *
+ */
+char const *dl_module_instance_name_by_data(void const *data)
+{
+ dl_module_inst_t const *inst;
+
+ inst = dl_module_instance_by_data(data);
+ if (!inst) return NULL;
+
+ return inst->name;
+}
+
/** A convenience function for returning a parent's private data
*
* @param[in] data Private instance data for child.
if (parent) {
module_name = talloc_typed_asprintf(NULL, "%s_%s_%s",
- fr_table_str_by_value(dl_module_type_prefix, parent->type, "<INVALID>"),
+ fr_table_str_by_value(dl_module_type_prefix,
+ parent->type, "<INVALID>"),
parent->common->name, name);
} else {
module_name = talloc_typed_asprintf(NULL, "%s_%s",
RCSID("$Id$")
#define LOG_PREFIX "rlm_always (%s) - "
-#define LOG_PREFIX_ARGS inst->name
+#define LOG_PREFIX_ARGS dl_module_instance_name_by_data(inst)
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module.h>
* going to return.
*/
typedef struct {
- char const *name; //!< Name of this instance of the always module.
char const *rcode_str; //!< The base value.
rlm_rcode_t rcode; //!< The integer constant representing rcode_str.
{
rlm_always_t *inst = instance;
- inst->name = cf_section_name1(conf);
- if (!inst->name) inst->name = cf_section_name2(conf);
/*
* Convert the rcode string to an int
*/