From 7a99ee14d236460129e5334f17816e336bd47d7c Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 26 Apr 2022 22:54:27 +0800 Subject: [PATCH] feature(rpc): add retry --- source/libs/transport/src/transCli.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index a4c54cdba7..57cf89e83d 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -887,7 +887,9 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { STransConnCtx* pCtx = pMsg->ctx; SEpSet* pEpSet = &pCtx->epSet; - + /* + * upper layer handle retry if code equal TSDB_CODE_RPC_NETWORK_UNAVAIL + */ tmsg_t msgType = pCtx->msgType; if ((pTransInst->retry != NULL && (pTransInst->retry(pResp->code))) || ((pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL) && msgType == TDMT_MND_CONNECT)) { @@ -897,10 +899,10 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { if (pCtx->retryCount < pEpSet->numOfEps) { pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; cliHandleReq(pMsg, pThrd); + cliDestroy((uv_handle_t*)pConn->stream); return -1; } - // cliDestroy((uv_handle_t*)pConn->stream); } else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) { if (pResp->contLen == 0) { pEpSet->inUse = (pEpSet->inUse++) % pEpSet->numOfEps; @@ -909,8 +911,9 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { tDeserializeSMEpSet(pResp->pCont, pResp->contLen, &emsg); pCtx->epSet = emsg.epSet; } - // release pConn cliHandleReq(pMsg, pThrd); + // release pConn + addConnToPool(pThrd, conn); return -1; } } -- GitLab