Merge pull request #1400 from taosdata/hotfix/rpcdeadlock

fix the deadlock bug for rpcCloseConn
This commit is contained in:
slguan 2020-03-22 08:55:52 +08:00 committed by GitHub
commit 7aa8791f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 24 deletions

View File

@ -287,7 +287,7 @@ void rpcClose(void *param) {
(*taosCleanUpConn[pRpc->connType])(pRpc->udphandle);
for (int i = 0; i < pRpc->sessions; ++i) {
if (pRpc->connList[i].user[0]) {
if (pRpc->connList && pRpc->connList[i].user[0]) {
rpcCloseConn((void *)(pRpc->connList + i));
}
}
@ -495,9 +495,10 @@ static void rpcCloseConn(void *thandle) {
SRpcConn *pConn = (SRpcConn *)thandle;
SRpcInfo *pRpc = pConn->pRpc;
if (pConn->user[0] == 0) return;
rpcLockConn(pConn);
if (pConn->user[0]) {
pConn->user[0] = 0;
if (taosCloseConn[pConn->connType]) (*taosCloseConn[pConn->connType])(pConn->chandle);
@ -522,7 +523,6 @@ static void rpcCloseConn(void *thandle) {
pConn->pContext = NULL;
tTrace("%s %p, rpc connection is closed", pRpc->label, pConn);
}
rpcUnlockConn(pConn);
}