From 1c14e570b1998478b3900f96bb3a7689cc41c4a0 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Sun, 8 Mar 2020 17:15:15 +0800 Subject: [PATCH] switch the sync query model to async query model --- src/client/src/tscSql.c | 13 ++++++++++++- src/client/src/tscUtil.c | 9 +++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index d86ca40554..465263a439 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -783,7 +783,13 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) { /* Query rsp is not received from vnode, so the qhandle is NULL */ tscTrace("%p qhandle is null, abort free, fp:%p", pSql, pSql->fp); if (pSql->fp != NULL) { - tscFreeSqlObj(pSql); + STscObj* pObj = pSql->pTscObj; + + if (pSql == pObj->pSql) { + pObj->pSql = NULL; + tscFreeSqlObj(pSql); + } + tscTrace("%p Async SqlObj is freed by app", pSql); } else if (keepCmd) { tscFreeSqlResult(pSql); @@ -850,6 +856,11 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) { tscFreeSqlObjPartial(pSql); tscTrace("%p sql result is freed by app", pSql); } + } else { // for async release, remove its link + STscObj* pObj = pSql->pTscObj; + if (pObj->pSql == pSql) { + pObj->pSql = NULL; + } } } else { // if no free resource msg is sent to vnode, we free this object immediately. diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index ae31637f4c..397ef2f0d0 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -460,11 +460,16 @@ void tscFreeSqlObjPartial(SSqlObj* pSql) { pthread_mutex_lock(&pObj->mutex); tfree(pSql->sqlstr); pthread_mutex_unlock(&pObj->mutex); - + tscFreeSqlResult(pSql); tfree(pSql->pSubs); pSql->numOfSubs = 0; - + + pSql->freed = 0; + tscFreeSqlCmdData(pCmd); + + tscTrace("%p free sqlObj partial completed", pSql); + tscFreeSqlCmdData(pCmd); } -- GitLab