From 70298585549442cda0dd9cd53278fe5408736021 Mon Sep 17 00:00:00 2001 From: tickduan <417921451@qq.com> Date: Sat, 5 Jun 2021 10:40:46 +0800 Subject: [PATCH] fix kill connection with _root user cause taosd crash --- src/client/src/tscProfile.c | 13 ++++--------- src/client/src/tscStream.c | 4 ++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index ea2a3d8228..7870ca7976 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -295,23 +295,18 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { } void tscKillConnection(STscObj *pObj) { + // get stream header by locked pthread_mutex_lock(&pObj->mutex); - - SSqlObj *pSql = pObj->sqlList; - while (pSql) { - pSql = pSql->next; - } - - SSqlStream *pStream = pObj->streamList; + pthread_mutex_unlock(&pObj->mutex); + while (pStream) { SSqlStream *tmp = pStream->next; + // taos_close_stream function call pObj->mutet lock , careful death-lock taos_close_stream(pStream); pStream = tmp; } - pthread_mutex_unlock(&pObj->mutex); - tscDebug("connection:%p is killed", pObj); taos_close(pObj); } diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index b60824b2fa..3fd727a745 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -141,6 +141,10 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) { pStream->numOfRes = 0; // reset the numOfRes. SSqlObj *pSql = pStream->pSql; + // pSql == NULL maybe killStream already called + if(pSql == NULL) { + return ; + } SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); tscDebug("0x%"PRIx64" add into timer", pSql->self); -- GitLab