From e96a6de3def951748a8c1bd9f3d074f73c594f1f Mon Sep 17 00:00:00 2001 From: valentin petrov Date: Wed, 4 May 2022 15:10:18 +0300 Subject: [PATCH] CL/HIER: team cleanup fix (#493) --- src/components/cl/hier/cl_hier_team.c | 19 +++++++++++-------- src/core/ucc_team.c | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/cl/hier/cl_hier_team.c b/src/components/cl/hier/cl_hier_team.c index 75560aaf2c..903ad6a9e0 100644 --- a/src/components/cl/hier/cl_hier_team.c +++ b/src/components/cl/hier/cl_hier_team.c @@ -52,12 +52,11 @@ UCC_CLASS_INIT_FUNC(ucc_cl_hier_team_t, ucc_base_context_t *cl_context, UCC_CLASS_CALL_SUPER_INIT(ucc_cl_team_t, &ctx->super, params); + memset(self->sbgps, 0, sizeof(self->sbgps)); ucc_cl_hier_enable_sbgps(self); n_sbgp_teams = 0; for (i = 0; i < UCC_HIER_SBGP_LAST; i++) { - hs = &self->sbgps[i]; - hs->score = NULL; - hs->sbgp = NULL; + hs = &self->sbgps[i]; if (hs->state == UCC_HIER_SBGP_ENABLED) { hs->sbgp = ucc_topo_get_sbgp(params->team->topo, hs->sbgp_type); if (hs->sbgp->status != UCC_SBGP_ENABLED) { @@ -176,12 +175,16 @@ ucc_status_t ucc_cl_hier_team_destroy(ucc_base_team_t *cl_team) for (i = 0; i < UCC_HIER_SBGP_LAST; i++) { hs = &team->sbgps[i]; if (hs->state == UCC_HIER_SBGP_ENABLED) { - ucc_coll_score_free_map(hs->score_map); + if (hs->score_map) { + ucc_coll_score_free_map(hs->score_map); + } for (j = 0; j < hs->n_tls; j++) { - ucc_tl_context_put(hs->tl_ctxs[j]); - team->team_create_req - ->descs[team->team_create_req->n_teams++] - .team = hs->tl_teams[j]; + if (hs->tl_teams[j]) { + ucc_tl_context_put(hs->tl_ctxs[j]); + team->team_create_req + ->descs[team->team_create_req->n_teams++] + .team = hs->tl_teams[j]; + } } } } diff --git a/src/core/ucc_team.c b/src/core/ucc_team.c index 507d44eec4..f72f4020c9 100644 --- a/src/core/ucc_team.c +++ b/src/core/ucc_team.c @@ -259,6 +259,7 @@ ucc_team_create_cls(ucc_context_t *context, ucc_team_t *team) if (status < 0) { team->n_cl_teams--; ucc_info("failed to create CL %s team", cl_iface->super.name); + cl_iface->team.destroy(b_team); } else if (status == UCC_INPROGRESS) { return status; } @@ -270,13 +271,12 @@ ucc_team_create_cls(ucc_context_t *context, ucc_team_t *team) &team->bp, &b_team); if (status != UCC_OK) { ucc_info("failed to create CL %s team", cl_iface->super.name); - /* TODO: see comment above*/ continue; } status = cl_iface->team.create_test(b_team); if (status < 0) { ucc_info("failed to create CL %s team", cl_iface->super.name); - /* TODO: see comment above */ + cl_iface->team.destroy(b_team); continue; } team->cl_teams[team->n_cl_teams++] =