未验证 提交 c7788d89 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #2368 from taosdata/hotfix/refCount

Hotfix/ref count
......@@ -577,15 +577,22 @@ static void rpcReleaseConn(SRpcConn *pConn) {
size_t size = snprintf(hashstr, sizeof(hashstr), "%x:%x:%x:%d", pConn->peerIp, pConn->linkUid, pConn->peerId, pConn->connType);
taosHashRemove(pRpc->hash, hashstr, size);
rpcFreeMsg(pConn->pRspMsg); // it may have a response msg saved, but not request msg
}
pConn->pRspMsg = NULL;
// 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));
pConn->lockedBy = lockedBy;
taosFreeId(pRpc->idPool, sid);
if (pConn->pReqMsg) rpcFreeCont(pConn->pReqMsg);
}
// memset could not be used, since lockeBy can not be reset
pConn->inType = 0;
pConn->outType = 0;
pConn->inTranId = 0;
pConn->outTranId = 0;
pConn->secured = 0;
pConn->pReqMsg = NULL;
pConn->reqMsgLen = 0;
pConn->pContext = NULL;
taosFreeId(pRpc->idPool, pConn->sid);
tTrace("%s, rpc connection is released", pConn->info);
}
......@@ -644,7 +651,6 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
terrno = TSDB_CODE_RPC_MAX_SESSIONS;
} else {
pConn = pRpc->connList + sid;
memset(pConn, 0, sizeof(SRpcConn));
memcpy(pConn->user, pHead->user, tListLen(pConn->user));
pConn->pRpc = pRpc;
pConn->sid = sid;
......@@ -885,6 +891,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
static void rpcReportBrokenLinkToServer(SRpcConn *pConn) {
SRpcInfo *pRpc = pConn->pRpc;
if (pConn->pReqMsg == NULL) return;
// if there are pending request, notify the app
rpcAddRef(pRpc);
......@@ -897,6 +904,8 @@ static void rpcReportBrokenLinkToServer(SRpcConn *pConn) {
rpcMsg.handle = pConn;
rpcMsg.msgType = pConn->inType;
rpcMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
pConn->pReqMsg = NULL;
pConn->reqMsgLen = 0;
if (pRpc->cfp) (*(pRpc->cfp))(&rpcMsg, NULL);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册