From: Arran Cudbard-Bell Date: Fri, 19 Jan 2018 02:00:27 +0000 (-0700) Subject: Various fixes in xlat_inst.c X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2fd06004f1625561bee7202a1a0ad9e2be5ccd11;p=thirdparty%2Ffreeradius-server.git Various fixes in xlat_inst.c --- diff --git a/src/include/xlat.h b/src/include/xlat.h index 6edf1e08fc7..8a852532b8a 100644 --- a/src/include/xlat.h +++ b/src/include/xlat.h @@ -105,7 +105,7 @@ typedef ssize_t (*xlat_func_sync_t)(TALLOC_CTX *ctx, char **out, size_t outlen, */ typedef xlat_action_t (*xlat_func_async_t)(TALLOC_CTX *ctx, fr_cursor_t *out, REQUEST *request, void const *xlat_inst, void *xlat_thread_inst, - fr_cursor_t const *in); + fr_cursor_t *in); /** Async xlat callback function * @@ -140,7 +140,7 @@ typedef xlat_action_t (*xlat_resume_callback_t)(TALLOC_CTX *ctx, fr_cursor_t *ou */ typedef int (*xlat_instantiate_t)(void *xlat_inst, xlat_exp_t const *exp, void *uctx); -/** Allocate new tread instance data for an xlat instance +/** Allocate new trhead instance data for an xlat instance * * @param[in] xlat_inst Previously instantiated xlat instance. * @param[out] xlat_thread_inst Thread specific structure to populate. diff --git a/src/main/xlat_inst.c b/src/main/xlat_inst.c index f21bee4e6ad..00b0b4c6fd2 100644 --- a/src/main/xlat_inst.c +++ b/src/main/xlat_inst.c @@ -118,36 +118,36 @@ static void _xlat_thread_inst_tree_free(void *to_free) * into xlat_thread_inst_tree. * - -1 on failure. */ -static xlat_thread_inst_t *xlat_thread_inst_alloc(xlat_exp_t *node) +static xlat_thread_inst_t *xlat_thread_inst_alloc(xlat_inst_t *inst) { xlat_thread_inst_t *thread_inst = NULL; - (void)talloc_get_type_abort(node, xlat_exp_t); + (void)talloc_get_type_abort(inst, xlat_inst_t); #ifdef HAVE_TALLOC_POOLED_OBJECT - if (node->xlat->thread_inst_size) { - MEM(thread_inst = talloc_pooled_object(NULL, xlat_thread_inst_t, node->xlat->thread_inst_size)) + if (inst->node->xlat->thread_inst_size) { + MEM(thread_inst = talloc_pooled_object(NULL, xlat_thread_inst_t, inst->node->xlat->thread_inst_size)) } else #endif MEM(thread_inst = talloc_zero(NULL, xlat_thread_inst_t)); #ifdef HAVE_TALLOC_POOLED_OBJECT } #endif - thread_inst->node = node; + thread_inst->node = inst->node; - rad_assert(node->type == XLAT_FUNC); - rad_assert(!node->thread_inst); /* May be missing inst, but this is OK */ + rad_assert(inst->node->type == XLAT_FUNC); + rad_assert(!inst->node->thread_inst); /* May be missing inst, but this is OK */ talloc_set_destructor(thread_inst, _xlat_thread_inst_detach); - if (node->xlat->thread_inst_size) { - MEM(thread_inst->data = talloc_zero_array(thread_inst, uint8_t, node->xlat->thread_inst_size)); + if (inst->node->xlat->thread_inst_size) { + MEM(thread_inst->data = talloc_zero_array(thread_inst, uint8_t, inst->node->xlat->thread_inst_size)); /* * This is expensive, only do it if we might * might be using it. */ #ifndef TALLOC_GET_TYPE_ABORT_NOOP - talloc_set_name(thread_inst, "%s_thread_inst_t", node->xlat->name); + talloc_set_name(thread_inst->data, "%s_xlat_thread_inst_t", inst->node->xlat->name); #endif } @@ -225,7 +225,7 @@ static xlat_inst_t *xlat_inst_alloc(xlat_exp_t *node) * might be using it. */ #ifndef TALLOC_GET_TYPE_ABORT_NOOP - talloc_set_name(inst, "%s_inst_t", node->xlat->name); + talloc_set_name(inst->data, "%s_xlat_inst_t", node->xlat->name); #endif } @@ -263,7 +263,7 @@ static int _xlat_instantiate_ephemeral_walker(xlat_exp_t *node, UNUSED void *uct /* * Create a thread instance too. */ - node->thread_inst = xlat_thread_inst_alloc(node); + node->thread_inst = xlat_thread_inst_alloc(node->inst); if (!node->thread_inst) goto error; if (node->xlat->thread_instantiate && @@ -295,15 +295,15 @@ int xlat_instantiate_ephemeral(xlat_exp_t *root) static int _xlat_thread_instantiate(UNUSED void *ctx, void *data) { xlat_thread_inst_t *thread_inst; - xlat_exp_t *node = talloc_get_type_abort(data, xlat_exp_t); + xlat_inst_t *inst = talloc_get_type_abort(data, xlat_inst_t); thread_inst = xlat_thread_inst_alloc(data); if (!thread_inst) return -1; - if (node->xlat->thread_instantiate) { + if (inst->node->xlat->thread_instantiate) { int ret; - ret = node->xlat->thread_instantiate(node->inst, thread_inst->data, node, node->xlat->uctx); + ret = inst->node->xlat->thread_instantiate(inst, thread_inst->data, inst->node, inst->node->xlat->uctx); if (ret < 0) { talloc_free(thread_inst); return -1;