From 97cb2e4d235364d5b703476a4d25ce4851b94089 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Wed, 11 Nov 2020 16:55:32 +0800 Subject: [PATCH 1/3] [TD-2063] not free result resource in async callback function --- tests/examples/c/asyncdemo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/examples/c/asyncdemo.c b/tests/examples/c/asyncdemo.c index 225c4f7541..2765dcd895 100644 --- a/tests/examples/c/asyncdemo.c +++ b/tests/examples/c/asyncdemo.c @@ -211,6 +211,8 @@ void taos_insert_call_back(void *param, TAOS_RES *tres, int code) printf("%lld mseconds to insert %d data points\n", (et - st) / 1000, points*numOfTables); } } + + taos_free_result(tres); } void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows) @@ -222,7 +224,7 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows) for (int i = 0; iname, numOfRows); - taos_free_result(tres); + //taos_free_result(tres); printf("%d rows data retrieved from %s\n", pTable->rowsRetrieved, pTable->name); tablesProcessed++; @@ -246,6 +248,8 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows) printf("%lld mseconds to query %d data rows\n", (et - st) / 1000, points * numOfTables); } } + + taos_free_result(tres); } void taos_select_call_back(void *param, TAOS_RES *tres, int code) @@ -263,4 +267,6 @@ void taos_select_call_back(void *param, TAOS_RES *tres, int code) printf("%s select failed, code:%d\n", pTable->name, code); exit(1); } + + taos_free_result(tres); } From 3a3fe63eabe60324bbbc5af36e8e67427bf4a3dc Mon Sep 17 00:00:00 2001 From: Hui Li Date: Wed, 11 Nov 2020 17:12:40 +0800 Subject: [PATCH 2/3] [TD-1973] no free result source in callback when use async api --- src/kit/taosdemo/taosdemo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 74dc239cb5..6178d91044 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -879,6 +879,7 @@ int main(int argc, char *argv[]) { taos_close(rInfo->taos); } + taos_cleanup(); return 0; } @@ -1325,6 +1326,8 @@ void callBack(void *param, TAOS_RES *res, int code) { if (code < 0) { fprintf(stderr, "failed to insert data %d:reason; %s\n", code, taos_errstr(res)); + taos_free_result(res); + taos_cleanup(); exit(EXIT_FAILURE); } @@ -1334,6 +1337,7 @@ void callBack(void *param, TAOS_RES *res, int code) { (*(tb_info->notFinished))--; if (*(tb_info->notFinished) == 0) tsem_post(tb_info->lock_sem); tsem_post(tb_info->mutex_sem); + taos_free_result(res); return; } @@ -1359,7 +1363,8 @@ void callBack(void *param, TAOS_RES *res, int code) { break; } } - tb_info->timestamp = tmp_time; + + tb_info->timestamp = tmp_time; taos_query_a(tb_info->taos, buffer, callBack, tb_info); From 5575b934bf3137582f1064984149eeaf9bafeac1 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Wed, 11 Nov 2020 17:36:52 +0800 Subject: [PATCH 3/3] [TD-2063] --- tests/examples/c/asyncdemo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/examples/c/asyncdemo.c b/tests/examples/c/asyncdemo.c index 2765dcd895..c6cc89b31d 100644 --- a/tests/examples/c/asyncdemo.c +++ b/tests/examples/c/asyncdemo.c @@ -68,6 +68,7 @@ static void queryDB(TAOS *taos, char *command) { fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql)); taos_free_result(pSql); taos_close(taos); + taos_cleanup(); exit(EXIT_FAILURE); } @@ -176,6 +177,7 @@ void taos_error(TAOS *con) { fprintf(stderr, "TDengine error: %s\n", taos_errstr(con)); taos_close(con); + taos_cleanup(); exit(1); } @@ -265,6 +267,8 @@ void taos_select_call_back(void *param, TAOS_RES *tres, int code) } else { printf("%s select failed, code:%d\n", pTable->name, code); + taos_free_result(tres); + taos_cleanup(); exit(1); }