From: Arran Cudbard-Bell Date: Wed, 10 Mar 2021 03:42:16 +0000 (+0000) Subject: Cache the child request name X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26d547a70c5bbde1d85444e416858e6458d2f642;p=thirdparty%2Ffreeradius-server.git Cache the child request name --- diff --git a/src/lib/unlang/parallel.c b/src/lib/unlang/parallel.c index b8a78a31032..694d50561c3 100644 --- a/src/lib/unlang/parallel.c +++ b/src/lib/unlang/parallel.c @@ -107,6 +107,7 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t RDEBUG3("parallel - child %s (%d/%d) INIT", child->name, i + 1, state->num_children); + state->children[i].name = talloc_bstrdup(state, child->name); if (state->detach) child_free = child; @@ -186,7 +187,7 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t case CHILD_RUNNABLE: runnable: RDEBUG2("parallel - child %s (%d/%d) continuing", - state->children[i].child->name, + state->children[i].name, i + 1, state->num_children); /* @@ -205,7 +206,7 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t } RDEBUG3("parallel - child %s (%d/%d) returns %s", - state->children[i].child->name, + state->children[i].name, i + 1, state->num_children, fr_table_str_by_value(mod_rcode_table, result, "")); @@ -236,7 +237,7 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t */ if (priority == MOD_ACTION_RETURN) { RDEBUG2("parallel - child %s (%d/%d) says 'return' - skipping the remaining children", - state->children[i].child->name, + state->children[i].name, i + 1, state->num_children); /* @@ -293,14 +294,14 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t fr_assert(state->children[i].instruction != NULL); RDEBUG3("parallel - child %s (%d/%d) YIELDED", - state->children[i].child->name, + state->children[i].name, i + 1, state->num_children); child_state = CHILD_YIELDED; continue; case CHILD_EXITED: RDEBUG3("parallel - child %s (%d/%d) EXITED", - state->children[i].child->name, + state->children[i].name, i + 1, state->num_children); state->children[i].state = CHILD_DONE; state->children[i].child = NULL; // someone else freed this somewhere @@ -312,7 +313,7 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t */ case CHILD_DONE: RDEBUG3("parallel - child %s (%d/%d) DONE", - state->children[i].child->name, + state->children[i].name, i + 1, state->num_children); fr_assert(state->children[i].child == NULL); fr_assert(state->children[i].instruction == NULL); @@ -424,10 +425,12 @@ static unlang_action_t unlang_parallel(rlm_rcode_t *p_result, request_t *request /* * Allocate an array for the children. */ - frame->state = state = talloc_zero_size(request, - sizeof(unlang_parallel_state_t) + - sizeof(state->children[0]) * - g->num_children); + MEM(frame->state = state = _talloc_zero_pooled_object(request, + sizeof(unlang_parallel_state_t) + + (sizeof(state->children[0]) * g->num_children), + "unlang_parallel_state_t", + g->num_children, + (talloc_array_length(request->name) * 2))); if (!state) { *p_result = RLM_MODULE_FAIL; return UNLANG_ACTION_CALCULATE_RESULT; diff --git a/src/lib/unlang/parallel_priv.h b/src/lib/unlang/parallel_priv.h index e71a392c930..1ce4b8cc501 100644 --- a/src/lib/unlang/parallel_priv.h +++ b/src/lib/unlang/parallel_priv.h @@ -48,26 +48,27 @@ typedef enum { */ typedef struct { unlang_parallel_child_state_t state; //!< State of the child. - request_t *child; //!< Child request. + request_t *child; //!< Child request. + char *name; //!< Cache the request name. unlang_t *instruction; //!< broken out of g->children } unlang_parallel_child_t; typedef struct { - rlm_rcode_t result; - int priority; + rlm_rcode_t result; + int priority; - int num_children; //!< How many children are executing. + int num_children; //!< How many children are executing. - bool detach; //!< are we creating the child detached - bool clone; //!< are the children cloned + bool detach; //!< are we creating the child detached + bool clone; //!< are the children cloned - unlang_parallel_child_t children[]; //!< Array of children. + unlang_parallel_child_t children[]; //!< Array of children. } unlang_parallel_state_t; typedef struct { - unlang_group_t group; - bool detach; //!< are we creating the child detached - bool clone; + unlang_group_t group; + bool detach; //!< are we creating the child detached + bool clone; } unlang_parallel_t; /** Cast a group structure to the parallel keyword extension