提交 be142916 编写于 作者: 陶建辉(Jeff)'s avatar 陶建辉(Jeff)

TD-1772

pThreadObj is freed when thread exits
上级 5c6bde88
......@@ -190,6 +190,7 @@ void dnodeFreeVnodeWqueue(void *wqueue) {
void dnodeSendRpcVnodeWriteRsp(void *pVnode, void *param, int32_t code) {
SWriteMsg *pWrite = (SWriteMsg *)param;
if (pWrite == NULL) return;
if (code < 0) pWrite->code = code;
int32_t count = atomic_add_fetch_32(&pWrite->processedCount, 1);
......
......@@ -174,6 +174,10 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
pThreadObj->stop = true;
eventfd_t fd = -1;
// save thread and pollFd into local variable since pThreadObj will be freed when thread exits
pthread_t thread = pThreadObj->thread;
int pollFd = pThreadObj->pollFd;
if (taosComparePthread(pThreadObj->thread, pthread_self())) {
pthread_detach(pthread_self());
return;
......@@ -196,8 +200,9 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
}
}
if (taosCheckPthreadValid(pThreadObj->thread) && pThreadObj->pollFd >= 0) {
pthread_join(pThreadObj->thread, NULL);
// at this step, pThreadObj may have been released
if (taosCheckPthreadValid(thread) && pollFd >= 0) {
pthread_join(thread, NULL);
}
if (fd != -1) taosCloseSocket(fd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册