From 76288100d8eb50507d6f25df93f311fb375f2cb5 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 26 Nov 2021 08:51:22 +0800 Subject: [PATCH] [TD-11383]fix tmp file name conflict issue --- src/os/src/detail/osFile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/os/src/detail/osFile.c b/src/os/src/detail/osFile.c index cc12968c72..039d688526 100644 --- a/src/os/src/detail/osFile.c +++ b/src/os/src/detail/osFile.c @@ -28,6 +28,7 @@ void taosClose(FileFd fd) { void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) { const char *tdengineTmpFileNamePrefix = "tdengine-"; char tmpPath[PATH_MAX]; + static uint64_t seqId = 0; int32_t len = (int32_t)strlen(tsTempDir); memcpy(tmpPath, tsTempDir, len); @@ -43,8 +44,10 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) { strcat(tmpPath, "-%d-%s"); } - char rand[8] = {0}; - taosRandStr(rand, tListLen(rand) - 1); + char rand[32] = {0}; + + sprintf(rand, "%" PRIu64, atomic_add_fetch_64(&seqId, 1)); + snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand); } -- GitLab