Skip to content

Commit

Permalink
DAOS-6808 rpc: fix memleak in MGMT_TGT_CREATE corpc (#5110)
Browse files Browse the repository at this point in the history
1. provide co_post_reply to free memory
2. change corpc to not call co_post_reply on root node.

Master-PR: #5037

Signed-off-by: Xuezhao Liu <xuezhao.liu@intel.com>
  • Loading branch information
liuxuezhao authored Mar 26, 2021
1 parent 9186db4 commit ed434c5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cart/crt_corpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,10 +729,14 @@ crt_corpc_reply_hdlr(const struct crt_cb_info *cb_info)
D_SPIN_UNLOCK(&parent_rpc_priv->crp_lock);

if (req_done) {
bool am_root;

RPC_ADDREF(parent_rpc_priv);
crt_corpc_complete(parent_rpc_priv);

if (co_ops && co_ops->co_post_reply)
am_root = (co_info->co_grp_priv->gp_self ==
co_info->co_root);
if (co_ops && co_ops->co_post_reply && !am_root)
co_ops->co_post_reply(&parent_rpc_priv->crp_pub,
co_info->co_priv);
RPC_DECREF(parent_rpc_priv);
Expand Down
1 change: 1 addition & 0 deletions src/mgmt/srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const int max_svc_nreplicas = 13;
static struct crt_corpc_ops ds_mgmt_hdlr_tgt_create_co_ops = {
.co_aggregate = ds_mgmt_tgt_create_aggregator,
.co_pre_forward = NULL,
.co_post_reply = ds_mgmt_tgt_create_post_reply,
};

static struct crt_corpc_ops ds_mgmt_hdlr_tgt_map_update_co_ops = {
Expand Down
1 change: 1 addition & 0 deletions src/mgmt/srv_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ void ds_mgmt_hdlr_tgt_create(crt_rpc_t *rpc_req);
void ds_mgmt_hdlr_tgt_destroy(crt_rpc_t *rpc_req);
int ds_mgmt_tgt_create_aggregator(crt_rpc_t *source, crt_rpc_t *result,
void *priv);
int ds_mgmt_tgt_create_post_reply(crt_rpc_t *rpc, void *priv);
void ds_mgmt_tgt_profile_hdlr(crt_rpc_t *rpc);
int ds_mgmt_tgt_map_update_pre_forward(crt_rpc_t *rpc, void *arg);
void ds_mgmt_hdlr_tgt_map_update(crt_rpc_t *rpc);
Expand Down
12 changes: 12 additions & 0 deletions src/mgmt/srv_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,18 @@ tgt_create(struct ds_pooltgts_rec *ptrec, uuid_t pool_uuid, uuid_t tgt_uuid,
return rc;
}

int
ds_mgmt_tgt_create_post_reply(crt_rpc_t *rpc, void *priv)
{
struct mgmt_tgt_create_out *tc_out;

tc_out = crt_reply_get(rpc);
D_FREE(tc_out->tc_tgt_uuids.ca_arrays);
D_FREE(tc_out->tc_ranks.ca_arrays);

return 0;
}

int
ds_mgmt_tgt_create_aggregator(crt_rpc_t *source, crt_rpc_t *result,
void *priv)
Expand Down

0 comments on commit ed434c5

Please sign in to comment.