From a99db2e39a2d48f0339c0a6a1551f8ea8942404f Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 8 May 2023 14:22:41 +0800 Subject: [PATCH 1/3] fix: memory leak --- source/client/src/clientEnv.c | 7 +++---- source/client/src/clientMain.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index c8f3feb2d4..500328ba79 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -388,11 +388,10 @@ void doDestroyRequest(void *p) { deregisterRequest(pRequest); } - if (pRequest->syncQuery) { - if (pRequest->body.param) { - tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem); - } + if (pRequest->body.param) { + tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem); taosMemoryFree(pRequest->body.param); + pRequest->body.param = NULL; } qDestroyQuery(pRequest->pQuery); diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 55465f227e..398186603f 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -1368,7 +1368,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { tsem_wait(&pParam->sem); _return: - taosArrayDestroy(catalogReq.pTableMeta); + taosArrayDestroyEx(catalogReq.pTableMeta, destoryTablesReq); destroyRequest(pRequest); return code; } From 49ad732517f917e70f8e8f57116a8c6cd4ae9c22 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 8 May 2023 15:00:40 +0800 Subject: [PATCH 2/3] chore: revert --- source/client/src/clientEnv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 500328ba79..c8f3feb2d4 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -388,10 +388,11 @@ void doDestroyRequest(void *p) { deregisterRequest(pRequest); } - if (pRequest->body.param) { - tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem); + if (pRequest->syncQuery) { + if (pRequest->body.param) { + tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem); + } taosMemoryFree(pRequest->body.param); - pRequest->body.param = NULL; } qDestroyQuery(pRequest->pQuery); From 8bd50809c95b4c6be5f9ec75239d3093d2e2c3ca Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 8 May 2023 15:47:10 +0800 Subject: [PATCH 3/3] chore: more code --- source/client/src/clientMain.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 398186603f..243a84ca93 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -1342,6 +1342,8 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { goto _return; } + pRequest->syncQuery = true; + STscObj *pTscObj = pRequest->pTscObj; code = transferTableNameList(tableNameList, pTscObj->acctId, pTscObj->db, &catalogReq.pTableMeta); if (code) {