From a61552783544ca3c1f6c70392475a1e30b31a51c Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Thu, 18 Jun 2020 10:03:33 +0000 Subject: [PATCH 1/2] free ID in the last step --- src/rpc/src/rpcMain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 365857a14e..71e1651ce1 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -576,11 +576,12 @@ static void rpcReleaseConn(SRpcConn *pConn) { taosHashRemove(pRpc->hash, hashstr, size); rpcFreeMsg(pConn->pRspMsg); // it may have a response msg saved, but not request msg } - - taosFreeId(pRpc->idPool, pConn->sid); + + int sid = pConn->sid; int64_t lockedBy = pConn->lockedBy; memset(pConn, 0, sizeof(SRpcConn)); pConn->lockedBy = lockedBy; + taosFreeId(pRpc->idPool, sid); tTrace("%s, rpc connection is released", pConn->info); } From ff16a84d59490dce236ede2de66acf81071ca139 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Thu, 18 Jun 2020 10:07:06 +0000 Subject: [PATCH 2/2] add comments --- src/rpc/src/rpcMain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 71e1651ce1..4a28cb4ff4 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -577,6 +577,7 @@ static void rpcReleaseConn(SRpcConn *pConn) { rpcFreeMsg(pConn->pRspMsg); // it may have a response msg saved, but not request msg } + // lockedBy can not be reset, since it maybe hold by a thread int sid = pConn->sid; int64_t lockedBy = pConn->lockedBy; memset(pConn, 0, sizeof(SRpcConn));