]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Parent thread instance data from the thread instance tree
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 4 Apr 2018 00:02:01 +0000 (01:02 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 4 Apr 2018 00:02:01 +0000 (01:02 +0100)
src/main/module.c
src/main/xlat_inst.c

index 8cf1f69b029fd1c80905e1b2a55a8a6b4999b51b..26589d79722ad17fe064a7a8a3cf64e653b412ef 100644 (file)
@@ -547,7 +547,7 @@ static int _module_thread_instantiate(void *instance, void *ctx)
        _thread_intantiate_ctx_t        *thread_inst_ctx = ctx;
        int                             ret;
 
-       MEM(ti = talloc_zero(NULL, module_thread_instance_t));
+       MEM(ti = talloc_zero(thread_inst_ctx->tree, module_thread_instance_t));
        ti->el = thread_inst_ctx->el;
        ti->module = mi->module;
        ti->mod_inst = mi->dl_inst->data;       /* For efficient lookups */
index 337e4d1e2855a91d560854e9d033e70a67117fe7..6bd27fc8cfde60bac178ab6192e8ba371fd27515 100644 (file)
@@ -107,6 +107,8 @@ static void _xlat_thread_inst_free(void *to_free)
 static void _xlat_thread_inst_tree_free(void *to_free)
 {
        rbtree_t *thread_inst_tree = talloc_get_type_abort(to_free , rbtree_t);
+
+       DEBUG3("Worker cleaning up xlat thread instance tree");
        talloc_free(thread_inst_tree);
 }
 
@@ -299,12 +301,12 @@ int xlat_instantiate_ephemeral(xlat_exp_t *root)
 /** Walker callback for xlat_inst_tree
  *
  */
-static int _xlat_thread_instantiate(UNUSED void *ctx, void *data)
+static int _xlat_thread_instantiate(void *ctx, void *data)
 {
        xlat_thread_inst_t      *thread_inst;
        xlat_inst_t             *inst = talloc_get_type_abort(data, xlat_inst_t);
 
-       thread_inst = xlat_thread_inst_alloc(NULL, data);
+       thread_inst = xlat_thread_inst_alloc(ctx, data);
        if (!thread_inst) return -1;
 
        DEBUG3("Instantiating xlat \"%s\" node %p, instance %p, new thread instance %p",
@@ -313,7 +315,8 @@ static int _xlat_thread_instantiate(UNUSED void *ctx, void *data)
        if (inst->node->xlat->thread_instantiate) {
                int ret;
 
-               ret = inst->node->xlat->thread_instantiate(inst->data, thread_inst->data, inst->node, inst->node->xlat->uctx);
+               ret = inst->node->xlat->thread_instantiate(inst->data, thread_inst->data,
+                                                          inst->node, inst->node->xlat->uctx);
                if (ret < 0) {
                        talloc_free(thread_inst);
                        return -1;
@@ -373,7 +376,7 @@ int xlat_thread_instantiate(void)
        /*
         *      Walk the inst tree, creating thread specific instances.
         */
-       ret = rbtree_walk(xlat_inst_tree, RBTREE_PRE_ORDER, _xlat_thread_instantiate, NULL);
+       ret = rbtree_walk(xlat_inst_tree, RBTREE_PRE_ORDER, _xlat_thread_instantiate, xlat_thread_inst_tree);
        if (ret < 0) {
                _xlat_thread_inst_tree_free(xlat_thread_inst_tree);     /* Destroy the thread_inst_tree if instantiation fails */
                return -1;