From 08e6c5ecf66caf0b4f5c54e8b3f0ae66561d7949 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 16 Nov 2020 10:27:16 +0000 Subject: [PATCH] [TD-1786]: failure of taos_clos may cause core --- src/rpc/src/rpcTcp.c | 3 +++ src/sync/src/taosTcpPool.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index affddf0520..7b8cf3cda2 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -173,6 +173,9 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread static void taosStopTcpThread(SThreadObj* pThreadObj) { // save thread into local variable and signal thread to stop pthread_t thread = pThreadObj->thread; + if (!taosCheckPthreadValid(thread)) { + return; + } pThreadObj->stop = true; if (taosComparePthread(thread, pthread_self())) { pthread_detach(pthread_self()); diff --git a/src/sync/src/taosTcpPool.c b/src/sync/src/taosTcpPool.c index 3be2989342..875528e66b 100644 --- a/src/sync/src/taosTcpPool.c +++ b/src/sync/src/taosTcpPool.c @@ -302,6 +302,9 @@ static SThreadObj *taosGetTcpThread(SPoolObj *pPool) { static void taosStopPoolThread(SThreadObj *pThread) { pthread_t thread = pThread->thread; + if (!taosCheckPthreadValid(thread)) { + return; + } pThread->stop = true; if (taosComparePthread(thread, pthread_self())) { pthread_detach(pthread_self()); -- GitLab