From 13d845935e9eb3168094632434815a839004906b Mon Sep 17 00:00:00 2001 From: Yaming Pei Date: Fri, 28 Feb 2025 16:01:28 +0800 Subject: [PATCH] feat: abort exit message when writing to csv --- tools/taos-tools/src/benchCsv.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/taos-tools/src/benchCsv.c b/tools/taos-tools/src/benchCsv.c index 97a1a74c0f..e7db3481b1 100644 --- a/tools/taos-tools/src/benchCsv.c +++ b/tools/taos-tools/src/benchCsv.c @@ -693,6 +693,11 @@ static void* csvGenStbThread(void* arg) { } ck += 1; + + if (!g_arguments->terminate) { + csvClose(fhdl); + goto end; + } } } @@ -705,13 +710,14 @@ static void* csvGenStbThread(void* arg) { end: csvFreeCtbTagData(tags_buf_bucket); - tmfree(cols_buf); + tmfree(buf); return NULL; } static int csvGenStbProcess(SDataBase* db, SSuperTable* stb) { int ret = 0; + bool prompt = true; CsvWriteMeta* write_meta = benchCalloc(1, sizeof(CsvWriteMeta), false); if (!write_meta) { @@ -751,6 +757,11 @@ static int csvGenStbProcess(SDataBase* db, SSuperTable* stb) { // wait threads for (uint32_t i = 0; i < write_meta->total_threads; ++i) { + if (g_arguments->terminate && prompt) { + infoPrint("Operation cancelled by user, exiting gracefully...\n"); + prompt = false; + } + infoPrint("pthread_join %d ...\n", i); pthread_join(pids[i], NULL); }