From da9bf993bdab43c2c2f4a791fe702b26f460ef59 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 10 Oct 2020 13:48:31 +0800 Subject: [PATCH] [td-1641] --- src/client/inc/tscUtil.h | 2 -- src/client/src/tscServer.c | 22 +++++++++++++--------- src/client/src/tscUtil.c | 7 ------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 0323434a99..3aff1b8ef3 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -207,8 +207,6 @@ void tscTagCondRelease(STagCond* pCond); void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo); -void tscSetFreeHeatBeat(STscObj* pObj); -bool tscShouldFreeHeartBeat(SSqlObj* pHb); bool tscShouldBeFreed(SSqlObj* pSql); STableMetaInfo* tscGetTableMetaInfoFromCmd(SSqlCmd *pCmd, int32_t subClauseIndex, int32_t tableIndex); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index de0c8d127d..5ec5de315e 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -198,15 +198,19 @@ void tscProcessActivityTimer(void *handle, void *tmrId) { return; } - if (tscShouldFreeHeartBeat(pHB)) { - tscDebug("%p free HB object and release connection", pHB); - pObj->pHb = 0; - taos_free_result(pHB); - } else { - int32_t code = tscProcessSql(pHB); - if (code != TSDB_CODE_SUCCESS) { - tscError("%p failed to sent HB to server, reason:%s", pHB, tstrerror(code)); - } + void** p = taosCacheAcquireByKey(tscObjCache, &pHB->self, sizeof(TSDB_CACHE_PTR_TYPE)); + if (p == NULL) { + tscWarn("%p HB object has been released already", pHB); + return; + } + + assert(*pHB->self == pHB); + + int32_t code = tscProcessSql(pHB); + taosCacheRelease(tscObjCache, (void**) &p, false); + + if (code != TSDB_CODE_SUCCESS) { + tscError("%p failed to sent HB to server, reason:%s", pHB, tstrerror(code)); } } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index d00b39e68b..f6bb97e52f 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1516,13 +1516,6 @@ void tscSetFreeHeatBeat(STscObj* pObj) { pQueryInfo->type = TSDB_QUERY_TYPE_FREE_RESOURCE; } -bool tscShouldFreeHeartBeat(SSqlObj* pHb) { - assert(pHb == pHb->signature); - - SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pHb->cmd, 0); - return pQueryInfo->type == TSDB_QUERY_TYPE_FREE_RESOURCE; -} - /* * the following four kinds of SqlObj should not be freed * 1. SqlObj for stream computing -- GitLab