This commit is contained in:
Jeff Tao 2020-10-03 04:30:02 +00:00
parent a8b8ecb20e
commit c608fba88e
3 changed files with 9 additions and 12 deletions

View File

@ -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);

View File

@ -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);
}
}
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;
}

View File

@ -324,5 +324,5 @@ static void taosStopPoolThread(SThreadObj *pThread) {
}
pthread_join(thread, NULL);
taosClose(fd);
if (fd >= 0) taosClose(fd);
}