From 36a2e334dbe0ae612779fdc64830849e13228044 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 22:05:45 +0800 Subject: [PATCH] set max redirect times --- src/rpc/src/rpcMain.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index cdd2d732e1..685b0f2b86 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -934,8 +934,15 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { // for UDP, port may be changed by server, the port in ipSet shall be used for cache rpcAddConnIntoCache(pRpc->pCache, pConn, pConn->peerFqdn, pContext->ipSet.port[pContext->ipSet.inUse], pConn->connType); + if (pHead->code == TSDB_CODE_REDIRECT) { + pContext->redirect++; + if (pContext->redirect > TSDB_MAX_REPLICA) { + pHead->code = TSDB_CODE_NETWORK_UNAVAIL; + tWarn("%s %p, too many redirects, quit", pRpc->label, pConn); + } + } + if (pHead->code == TSDB_CODE_REDIRECT) { - pContext->redirect = 1; pContext->numOfTry = 0; memcpy(&pContext->ipSet, pHead->content, sizeof(pContext->ipSet)); tTrace("%s %p, redirect is received, numOfIps:%d", pRpc->label, pConn, pContext->ipSet.numOfIps); -- GitLab