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

pThreadObj may have been freed, so use local copy of pThreadObj->thread

上级 f5ce39b3
...@@ -177,12 +177,12 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) { ...@@ -177,12 +177,12 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
// save thread into local variable since pThreadObj is freed when thread exits // save thread into local variable since pThreadObj is freed when thread exits
pthread_t thread = pThreadObj->thread; pthread_t thread = pThreadObj->thread;
if (taosComparePthread(pThreadObj->thread, pthread_self())) { if (taosComparePthread(thread, pthread_self())) {
pthread_detach(pthread_self()); pthread_detach(pthread_self());
return; return;
} }
if (taosCheckPthreadValid(pThreadObj->thread)) { if (taosCheckPthreadValid(thread)) {
// signal the thread to stop, try graceful method first, // signal the thread to stop, try graceful method first,
// and use pthread_cancel when failed // and use pthread_cancel when failed
struct epoll_event event = { .events = EPOLLIN }; struct epoll_event event = { .events = EPOLLIN };
...@@ -191,11 +191,11 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) { ...@@ -191,11 +191,11 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
// failed to create eventfd, call pthread_cancel instead, which may result in data corruption: // failed to create eventfd, call pthread_cancel instead, which may result in data corruption:
tError("%s, failed to create eventfd(%s)", pThreadObj->label, strerror(errno)); tError("%s, failed to create eventfd(%s)", pThreadObj->label, strerror(errno));
pThreadObj->stop = true; pThreadObj->stop = true;
pthread_cancel(pThreadObj->thread); pthread_cancel(thread);
} else if (epoll_ctl(pThreadObj->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) { } else if (epoll_ctl(pThreadObj->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) {
// failed to call epoll_ctl, call pthread_cancel instead, which may result in data corruption: // failed to call epoll_ctl, call pthread_cancel instead, which may result in data corruption:
tError("%s, failed to call epoll_ctl(%s)", pThreadObj->label, strerror(errno)); tError("%s, failed to call epoll_ctl(%s)", pThreadObj->label, strerror(errno));
pthread_cancel(pThreadObj->thread); pthread_cancel(thread);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册