提交 317adb16 编写于 作者: dengyihao's avatar dengyihao

feature(rpc): add retry

上级 c08fcc62
...@@ -887,8 +887,19 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { ...@@ -887,8 +887,19 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
STransConnCtx* pCtx = pMsg->ctx; STransConnCtx* pCtx = pMsg->ctx;
SEpSet* pEpSet = &pCtx->epSet; SEpSet* pEpSet = &pCtx->epSet;
if (pTransInst->retry != NULL && pTransInst->retry(pResp->code) && pCtx->retryCount <= TRANS_RETRY_COUNT_LIMIT) {
tmsg_t msgType = pCtx->msgType;
if ((pTransInst->retry != NULL && (pTransInst->retry(pResp->code))) ||
((pResp->code != 0) && msgType == TDMT_MND_CONNECT)) {
pCtx->retryCount += 1; pCtx->retryCount += 1;
pMsg->st = taosGetTimestampUs();
if (msgType == TDMT_MND_CONNECT) {
if (pCtx->retryCount < pEpSet->numOfEps) {
pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps;
cliHandleReq(pMsg, pThrd);
return -1;
}
} else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) {
if (pResp->contLen == 0) { if (pResp->contLen == 0) {
pEpSet->inUse = (pEpSet->inUse++) % pEpSet->numOfEps; pEpSet->inUse = (pEpSet->inUse++) % pEpSet->numOfEps;
} else { } else {
...@@ -900,6 +911,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { ...@@ -900,6 +911,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
cliHandleReq(pMsg, pThrd); cliHandleReq(pMsg, pThrd);
return -1; return -1;
} }
}
if (pCtx->pSem != NULL) { if (pCtx->pSem != NULL) {
tTrace("%s cli conn %p handle resp", pTransInst->label, pConn); tTrace("%s cli conn %p handle resp", pTransInst->label, pConn);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册