diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 46555b364770b412bf7524eb28352f807ff530a2..06b5d39d6154af55b59fc6662c1ecb622c55e77e 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -196,7 +196,10 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) { } } - if (taosCheckPthreadValid(pThreadObj->thread) && pThreadObj->pollFd >= 0) pthread_join(pThreadObj->thread, NULL); + if (taosCheckPthreadValid(pThreadObj->thread) && pThreadObj->pollFd >= 0) { + pthread_join(pThreadObj->thread, NULL); + } + if (fd != -1) taosCloseSocket(fd); } @@ -225,7 +228,6 @@ void taosCleanUpTcpServer(void *handle) { for (int i = 0; i < pServerObj->numOfThreads; ++i) { pThreadObj = pServerObj->pThreadObj[i]; taosStopTcpThread(pThreadObj); - pthread_mutex_destroy(&(pThreadObj->mutex)); } tDebug("%s TCP server is cleaned up", pServerObj->label); @@ -526,6 +528,7 @@ static void *taosProcessTcpData(void *param) { taosFreeFdObj(pFdObj); } + pthread_mutex_destroy(&(pThreadObj->mutex)); tDebug("%s TCP thread exits ...", pThreadObj->label); taosTFree(pThreadObj); diff --git a/src/rpc/src/rpcUdp.c b/src/rpc/src/rpcUdp.c index 4fd0318ae6692c2e7573229a8d602558f460dd3f..4ea47582b9c93fbd483454a50e1bf6aed5237870 100644 --- a/src/rpc/src/rpcUdp.c +++ b/src/rpc/src/rpcUdp.c @@ -140,18 +140,15 @@ void taosStopUdpConnection(void *handle) { pConn = pSet->udpConn + i; if (pConn->fd >=0) shutdown(pConn->fd, SHUT_RDWR); if (pConn->fd >=0) taosCloseSocket(pConn->fd); - pConn->fd = -1; } for (int i = 0; i < pSet->threads; ++i) { pConn = pSet->udpConn + i; if (taosCheckPthreadValid(pConn->thread)) { - if (taosComparePthread(pConn->thread, pthread_self())) { - pthread_detach(pthread_self()); - } else { - pthread_join(pConn->thread, NULL); - } + pthread_join(pConn->thread, NULL); } + taosTFree(pConn->buffer); + // tTrace("%s UDP thread is closed, index:%d", pConn->label, i); } tDebug("%s UDP is stopped", pSet->label); @@ -233,9 +230,6 @@ static void *taosRecvUdpData(void *param) { (*(pConn->processData))(&recvInfo); } - taosTFree(pConn->buffer); - tDebug("%s UDP recv thread exits", pConn->label); - return NULL; } diff --git a/src/sync/src/taosTcpPool.c b/src/sync/src/taosTcpPool.c index 539cfb64da452cf5fcfa148c724da9609aa8499c..6a210a136ffe67b2e1394d26bac4cb5083452c8c 100644 --- a/src/sync/src/taosTcpPool.c +++ b/src/sync/src/taosTcpPool.c @@ -324,5 +324,5 @@ static void taosStopPoolThread(SThreadObj *pThread) { } pthread_join(thread, NULL); - taosClose(fd); + if (fd >= 0) taosClose(fd); }