Merge pull request #4190 from taosdata/hotfix/test

[TD-2063]<fix> not free result resource in async callback function
This commit is contained in:
huili 2020-11-12 13:58:45 +08:00 committed by GitHub
commit 1c3066963a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -881,6 +881,7 @@ int main(int argc, char *argv[]) {
taos_close(rInfo->taos); taos_close(rInfo->taos);
} }
taos_cleanup();
return 0; return 0;
} }

View File

@ -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)
{ {
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)
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)
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)
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)
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)
} }
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);
} }