Skip to content

Commit

Permalink
DAOS-16170 cart: refine corpc fail handling for CRT_RPC_FLAG_CO_FAILOUT
Browse files Browse the repository at this point in the history
reset rc to 0 to avoid unnecessary RPC_DECREF in fail case in
crt_req_send.

Signed-off-by: Xuezhao Liu <[email protected]>
  • Loading branch information
liuxuezhao committed Dec 7, 2024
1 parent ab5815d commit a097c82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/cart/crt_corpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ crt_corpc_req_hdlr(struct crt_rpc_priv *rpc_priv)
struct crt_opc_info *opc_info;
struct crt_corpc_ops *co_ops;
bool ver_match;
bool co_failout = false;
int i, rc = 0;

co_info = rpc_priv->crp_corpc_info;
Expand Down Expand Up @@ -906,18 +907,18 @@ crt_corpc_req_hdlr(struct crt_rpc_priv *rpc_priv)
}

forward_done:
if (rc != 0 && rpc_priv->crp_flags & CRT_RPC_FLAG_CO_FAILOUT) {
crt_corpc_complete(rpc_priv);
goto out;
}
if (rc != 0 && rpc_priv->crp_flags & CRT_RPC_FLAG_CO_FAILOUT)
co_failout = true;

/* NOOP bcast (no child and root excluded) */
if (co_info->co_child_num == 0 && co_info->co_root_excluded)
if (co_info->co_child_num == 0 && (co_info->co_root_excluded || co_failout))
crt_corpc_complete(rpc_priv);

if (co_info->co_root_excluded == 1) {
if (co_info->co_root_excluded == 1 || co_failout) {
if (co_info->co_grp_priv->gp_self == co_info->co_root) {
/* don't return error for root */
/* don't return error for root to avoid RPC_DECREF in
* fail case in crt_req_send.
*/
rc = 0;
}
D_GOTO(out, rc);
Expand Down
2 changes: 1 addition & 1 deletion src/cart/crt_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ crt_req_send(crt_rpc_t *req, crt_cb_t complete_cb, void *arg)
/* failure already reported through complete cb */
if (complete_cb != NULL)
rc = 0;
} else if (!crt_rpc_completed(rpc_priv)) {
} else {
RPC_DECREF(rpc_priv);
}
}
Expand Down

0 comments on commit a097c82

Please sign in to comment.