未验证 提交 1c306696 编写于 作者: H huili 提交者: GitHub

Merge pull request #4190 from taosdata/hotfix/test

[TD-2063]<fix> not free result resource in async callback function
...@@ -881,6 +881,7 @@ int main(int argc, char *argv[]) { ...@@ -881,6 +881,7 @@ int main(int argc, char *argv[]) {
taos_close(rInfo->taos); taos_close(rInfo->taos);
} }
taos_cleanup();
return 0; return 0;
} }
......
...@@ -68,6 +68,7 @@ static void queryDB(TAOS *taos, char *command) { ...@@ -68,6 +68,7 @@ static void queryDB(TAOS *taos, char *command) {
fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql)); fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql));
taos_free_result(pSql); taos_free_result(pSql);
taos_close(taos); taos_close(taos);
taos_cleanup();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -176,6 +177,7 @@ void taos_error(TAOS *con) ...@@ -176,6 +177,7 @@ void taos_error(TAOS *con)
{ {
fprintf(stderr, "TDengine error: %s\n", taos_errstr(con)); fprintf(stderr, "TDengine error: %s\n", taos_errstr(con));
taos_close(con); taos_close(con);
taos_cleanup();
exit(1); exit(1);
} }
...@@ -211,6 +213,8 @@ void taos_insert_call_back(void *param, TAOS_RES *tres, int code) ...@@ -211,6 +213,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); 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) void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows)
...@@ -222,7 +226,7 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows) ...@@ -222,7 +226,7 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows)
for (int i = 0; i<numOfRows; ++i) { for (int i = 0; i<numOfRows; ++i) {
// synchronous API to retrieve a row from batch of records // synchronous API to retrieve a row from batch of records
/*TAOS_ROW row = */taos_fetch_row(tres); /*TAOS_ROW row = */(void)taos_fetch_row(tres);
// process row // process row
} }
...@@ -236,7 +240,7 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows) ...@@ -236,7 +240,7 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows)
if (numOfRows < 0) if (numOfRows < 0)
printf("%s retrieve failed, code:%d\n", pTable->name, numOfRows); printf("%s retrieve failed, code:%d\n", pTable->name, numOfRows);
taos_free_result(tres); //taos_free_result(tres);
printf("%d rows data retrieved from %s\n", pTable->rowsRetrieved, pTable->name); printf("%d rows data retrieved from %s\n", pTable->rowsRetrieved, pTable->name);
tablesProcessed++; tablesProcessed++;
...@@ -246,6 +250,8 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows) ...@@ -246,6 +250,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); 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) void taos_select_call_back(void *param, TAOS_RES *tres, int code)
...@@ -261,6 +267,10 @@ void taos_select_call_back(void *param, TAOS_RES *tres, int code) ...@@ -261,6 +267,10 @@ void taos_select_call_back(void *param, TAOS_RES *tres, int code)
} }
else { else {
printf("%s select failed, code:%d\n", pTable->name, code); printf("%s select failed, code:%d\n", pTable->name, code);
taos_free_result(tres);
taos_cleanup();
exit(1); exit(1);
} }
taos_free_result(tres);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册