diff --git a/src/cart/crt_hg.c b/src/cart/crt_hg.c index f34cc0af9ff..97d8fe83e39 100644 --- a/src/cart/crt_hg.c +++ b/src/cart/crt_hg.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2016-2023 Intel Corporation. + * (C) Copyright 2016-2024 Intel Corporation. * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -1506,6 +1506,8 @@ crt_hg_reply_send(struct crt_rpc_priv *rpc_priv) D_ASSERT(rpc_priv != NULL); RPC_ADDREF(rpc_priv); + + /* Input buffer still used during HG_Respond*/ hg_ret = HG_Respond(rpc_priv->crp_hg_hdl, crt_hg_reply_send_cb, rpc_priv, &rpc_priv->crp_pub.cr_output); if (hg_ret != HG_SUCCESS) { @@ -1516,6 +1518,17 @@ crt_hg_reply_send(struct crt_rpc_priv *rpc_priv) rc = crt_hgret_2_der(hg_ret); } + /* Don't release input for forwarded RPCs as they share input with a parent */ + if (!rpc_priv->crp_forward) { + /* Release input buffer */ + hg_ret = HG_Release_input_buf(rpc_priv->crp_hg_hdl); + if (hg_ret != HG_SUCCESS) { + RPC_ERROR(rpc_priv, "HG_Release_input_buf failed, hg_ret: " DF_HG_RC "\n", + DP_HG_RC(hg_ret)); + /* Fall through */ + } + } + return rc; } @@ -1540,6 +1553,18 @@ crt_hg_reply_error_send(struct crt_rpc_priv *rpc_priv, int error_code) "Sent CART level error message back to client. error_code: %d\n", error_code); } + + /* Don't release input for forwarded RPCs as they share input with a parent */ + if (!rpc_priv->crp_forward) { + /* Release input buffer */ + hg_ret = HG_Release_input_buf(rpc_priv->crp_hg_hdl); + if (hg_ret != HG_SUCCESS) { + RPC_ERROR(rpc_priv, "HG_Release_input_buf failed, hg_ret: " DF_HG_RC "\n", + DP_HG_RC(hg_ret)); + /* Fall through */ + } + } + rpc_priv->crp_reply_pending = 0; }