feat: abort exit message when writing to csv

This commit is contained in:
Yaming Pei 2025-02-28 16:01:28 +08:00
parent 32b575f73a
commit 13d845935e
1 changed files with 12 additions and 1 deletions

View File

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