fix: set stack size to 8 MB for windows and dup fd for gzdopen

This commit is contained in:
kailixu 2023-09-12 13:33:12 +08:00
parent 6357032cd6
commit 2f9ab38fd0
2 changed files with 16 additions and 2 deletions

View File

@ -176,6 +176,14 @@ IF(APPLE)
set(THREADS_PREFER_PTHREAD_FLAG ON)
ENDIF()
IF(TD_WINDOWS)
IF(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:8388608")
ELSEIF(MINGW)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,8388608")
ENDIF()
ENDIF()
MESSAGE(STATUS "Platform arch:" ${PLATFORM_ARCH_STR})
set(TD_DEPS_DIR "x86")

View File

@ -926,10 +926,16 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) {
goto cmp_end;
}
dstFp = gzdopen(pFile->fd, "wb6f");
// Both gzclose() and fclose() will close the associated fd, so they need to have different fds.
FileFd gzFd = dup(pFile->fd);
if (gzFd < 0) {
ret = -4;
goto cmp_end;
}
dstFp = gzdopen(gzFd, "wb6f");
if (dstFp == NULL) {
ret = -3;
taosCloseFile(&pFile);
close(gzFd);
goto cmp_end;
}