From ee93500619e91ff6e7851171c2b38ec9d13859f8 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Tue, 25 Apr 2023 17:03:58 +0800 Subject: [PATCH] fix: log file size over 4G report error on windows --- source/os/src/osFile.c | 3 ++- source/util/src/tlog.c | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index aab547223f..9833e3ba45 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -538,10 +538,11 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) { return -1; } - struct stat fileStat; #ifdef WINDOWS + struct __stat64 fileStat; int32_t code = _fstat(pFile->fd, &fileStat); #else + struct stat fileStat; int32_t code = fstat(pFile->fd, &fileStat); #endif if (code < 0) { diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 2a18f420cd..d415379f92 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -347,7 +347,6 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) { char name[LOG_FILE_NAME_LEN + 50] = "\0"; int32_t logstat0_mtime, logstat1_mtime; - int32_t size; tsLogObj.maxLines = maxLines; tsLogObj.fileNum = maxFileNum; @@ -395,8 +394,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) { printf("\nfailed to fstat log file:%s, reason:%s\n", fileName, strerror(errno)); return -1; } - size = (int32_t)filesize; - tsLogObj.lines = size / 60; + tsLogObj.lines = (int32_t)(filesize / 60); taosLSeekFile(tsLogObj.logHandle->pFile, 0, SEEK_END); -- GitLab