From: Alan T. DeKok Date: Thu, 19 Oct 2017 13:30:07 +0000 (-0400) Subject: clean up children immediately on "return" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7f4bc532430c84fea2d35b01316f154367d09ce;p=thirdparty%2Ffreeradius-server.git clean up children immediately on "return" --- diff --git a/src/main/unlang_interpret.c b/src/main/unlang_interpret.c index 50544f248af..cb6f17a73fd 100644 --- a/src/main/unlang_interpret.c +++ b/src/main/unlang_interpret.c @@ -1057,11 +1057,16 @@ static rlm_rcode_t unlang_parallel_run(REQUEST *request, unlang_parallel_t *stat * parallel section". */ if (priority == MOD_ACTION_RETURN) { - priority = 0; - done = CHILD_DONE; RDEBUG("child %d/%d says 'return' - skipping the remaining children", i + 1, state->num_children); + + /* + * Fall through to processing the + * priorities and return codes. + */ i = state->num_children; + priority = 0; + done = CHILD_DONE; } /* @@ -1108,6 +1113,19 @@ static rlm_rcode_t unlang_parallel_run(REQUEST *request, unlang_parallel_t *stat rad_assert(done = CHILD_DONE); + /* + * Clean up all of the children as soon as possible. + */ + for (i = 0; i < state->num_children; i++) { + if ((state->children[i].state == CHILD_YIELDED) || + (state->children[i].state == CHILD_RUNNABLE)) { + TALLOC_FREE(state->children[i].child); + } + + state->children[i].state = CHILD_DONE; + state->children[i].instruction = NULL; + } + /* * Return the final result. The caller will take care of * free'ing "state".