fix(os): win ctest error
This commit is contained in:
parent
403b2ba1c2
commit
93a0c69edc
|
@ -46,7 +46,7 @@ ENDIF ()
|
|||
|
||||
IF (TD_WINDOWS)
|
||||
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||
SET(COMMON_FLAGS "/w /D_WIN32")
|
||||
SET(COMMON_FLAGS "/w /D_WIN32 /Zi")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
||||
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
||||
|
|
|
@ -100,8 +100,10 @@ endif(${BUILD_WITH_NURAFT})
|
|||
|
||||
# addr2line
|
||||
if(${BUILD_ADDR2LINE})
|
||||
cat("${TD_SUPPORT_DIR}/libdwarf_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
cat("${TD_SUPPORT_DIR}/addr2line_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
if(NOT ${TD_WINDOWS})
|
||||
cat("${TD_SUPPORT_DIR}/libdwarf_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
cat("${TD_SUPPORT_DIR}/addr2line_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
endif(NOT ${TD_WINDOWS})
|
||||
endif(${BUILD_ADDR2LINE})
|
||||
|
||||
# download dependencies
|
||||
|
@ -335,45 +337,47 @@ endif(${BUILD_WITH_SQLITE})
|
|||
|
||||
# addr2line
|
||||
if(${BUILD_ADDR2LINE})
|
||||
check_include_file( "sys/types.h" HAVE_SYS_TYPES_H)
|
||||
check_include_file( "sys/stat.h" HAVE_SYS_STAT_H )
|
||||
check_include_file( "inttypes.h" HAVE_INTTYPES_H )
|
||||
check_include_file( "stddef.h" HAVE_STDDEF_H )
|
||||
check_include_file( "stdlib.h" HAVE_STDLIB_H )
|
||||
check_include_file( "string.h" HAVE_STRING_H )
|
||||
check_include_file( "memory.h" HAVE_MEMORY_H )
|
||||
check_include_file( "strings.h" HAVE_STRINGS_H )
|
||||
check_include_file( "stdint.h" HAVE_STDINT_H )
|
||||
check_include_file( "unistd.h" HAVE_UNISTD_H )
|
||||
check_include_file( "sgidefs.h" HAVE_SGIDEFS_H )
|
||||
check_include_file( "stdafx.h" HAVE_STDAFX_H )
|
||||
check_include_file( "elf.h" HAVE_ELF_H )
|
||||
check_include_file( "libelf.h" HAVE_LIBELF_H )
|
||||
check_include_file( "libelf/libelf.h" HAVE_LIBELF_LIBELF_H)
|
||||
check_include_file( "alloca.h" HAVE_ALLOCA_H )
|
||||
check_include_file( "elfaccess.h" HAVE_ELFACCESS_H)
|
||||
check_include_file( "sys/elf_386.h" HAVE_SYS_ELF_386_H )
|
||||
check_include_file( "sys/elf_amd64.h" HAVE_SYS_ELF_AMD64_H)
|
||||
check_include_file( "sys/elf_sparc.h" HAVE_SYS_ELF_SPARC_H)
|
||||
check_include_file( "sys/ia64/elf.h" HAVE_SYS_IA64_ELF_H )
|
||||
set(VERSION 0.3.1)
|
||||
set(PACKAGE_VERSION "\"${VERSION}\"")
|
||||
configure_file(libdwarf/cmake/config.h.cmake config.h)
|
||||
file(GLOB_RECURSE LIBDWARF_SOURCES "libdwarf/src/lib/libdwarf/*.c")
|
||||
add_library(libdwarf STATIC ${LIBDWARF_SOURCES})
|
||||
set_target_properties(libdwarf PROPERTIES OUTPUT_NAME "libdwarf")
|
||||
if(HAVE_LIBELF_H OR HAVE_LIBELF_LIBELF_H)
|
||||
target_link_libraries(libdwarf PUBLIC libelf)
|
||||
endif()
|
||||
target_include_directories(libdwarf SYSTEM PUBLIC "libdwarf/src/lib/libdwarf" ${CMAKE_CURRENT_BINARY_DIR})
|
||||
file(READ "addr2line/addr2line.c" ADDR2LINE_CONTENT)
|
||||
string(REPLACE "static int" "int" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
||||
string(REPLACE "static void" "void" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
||||
string(REPLACE "main(" "main_addr2line(" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
||||
file(WRITE "addr2line/addr2line.c" "${ADDR2LINE_CONTENT}")
|
||||
add_library(addr2line STATIC "addr2line/addr2line.c")
|
||||
target_link_libraries(addr2line PUBLIC libdwarf dl z)
|
||||
target_include_directories(addr2line PUBLIC "libdwarf/src/lib/libdwarf" )
|
||||
if(NOT ${TD_WINDOWS})
|
||||
check_include_file( "sys/types.h" HAVE_SYS_TYPES_H)
|
||||
check_include_file( "sys/stat.h" HAVE_SYS_STAT_H )
|
||||
check_include_file( "inttypes.h" HAVE_INTTYPES_H )
|
||||
check_include_file( "stddef.h" HAVE_STDDEF_H )
|
||||
check_include_file( "stdlib.h" HAVE_STDLIB_H )
|
||||
check_include_file( "string.h" HAVE_STRING_H )
|
||||
check_include_file( "memory.h" HAVE_MEMORY_H )
|
||||
check_include_file( "strings.h" HAVE_STRINGS_H )
|
||||
check_include_file( "stdint.h" HAVE_STDINT_H )
|
||||
check_include_file( "unistd.h" HAVE_UNISTD_H )
|
||||
check_include_file( "sgidefs.h" HAVE_SGIDEFS_H )
|
||||
check_include_file( "stdafx.h" HAVE_STDAFX_H )
|
||||
check_include_file( "elf.h" HAVE_ELF_H )
|
||||
check_include_file( "libelf.h" HAVE_LIBELF_H )
|
||||
check_include_file( "libelf/libelf.h" HAVE_LIBELF_LIBELF_H)
|
||||
check_include_file( "alloca.h" HAVE_ALLOCA_H )
|
||||
check_include_file( "elfaccess.h" HAVE_ELFACCESS_H)
|
||||
check_include_file( "sys/elf_386.h" HAVE_SYS_ELF_386_H )
|
||||
check_include_file( "sys/elf_amd64.h" HAVE_SYS_ELF_AMD64_H)
|
||||
check_include_file( "sys/elf_sparc.h" HAVE_SYS_ELF_SPARC_H)
|
||||
check_include_file( "sys/ia64/elf.h" HAVE_SYS_IA64_ELF_H )
|
||||
set(VERSION 0.3.1)
|
||||
set(PACKAGE_VERSION "\"${VERSION}\"")
|
||||
configure_file(libdwarf/cmake/config.h.cmake config.h)
|
||||
file(GLOB_RECURSE LIBDWARF_SOURCES "libdwarf/src/lib/libdwarf/*.c")
|
||||
add_library(libdwarf STATIC ${LIBDWARF_SOURCES})
|
||||
set_target_properties(libdwarf PROPERTIES OUTPUT_NAME "libdwarf")
|
||||
if(HAVE_LIBELF_H OR HAVE_LIBELF_LIBELF_H)
|
||||
target_link_libraries(libdwarf PUBLIC libelf)
|
||||
endif()
|
||||
target_include_directories(libdwarf SYSTEM PUBLIC "libdwarf/src/lib/libdwarf" ${CMAKE_CURRENT_BINARY_DIR})
|
||||
file(READ "addr2line/addr2line.c" ADDR2LINE_CONTENT)
|
||||
string(REPLACE "static int" "int" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
||||
string(REPLACE "static void" "void" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
||||
string(REPLACE "main(" "main_addr2line(" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
||||
file(WRITE "addr2line/addr2line.c" "${ADDR2LINE_CONTENT}")
|
||||
add_library(addr2line STATIC "addr2line/addr2line.c")
|
||||
target_link_libraries(addr2line PUBLIC libdwarf dl z)
|
||||
target_include_directories(addr2line PUBLIC "libdwarf/src/lib/libdwarf" )
|
||||
endif(NOT ${TD_WINDOWS})
|
||||
endif(${BUILD_ADDR2LINE})
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -72,12 +72,20 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) {
|
|||
char path[PATH_MAX] = {0};
|
||||
if (tsProcPath == NULL) {
|
||||
path[0] = '.';
|
||||
#ifdef WINDOWS
|
||||
GetModuleFileName(NULL, path, PATH_MAX);
|
||||
taosDirName(path);
|
||||
#endif
|
||||
} else {
|
||||
strncpy(path, tsProcPath, strlen(tsProcPath));
|
||||
taosDirName(path);
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
strcat(path, "udfd.exe");
|
||||
if (strlen(path)==0) {
|
||||
strcat(path, "udfd.exe");
|
||||
} else {
|
||||
strcat(path, "\\udfd.exe");
|
||||
}
|
||||
#else
|
||||
strcat(path, "/udfd");
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "planTestUtil.h"
|
||||
#include <getopt.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
|
|
@ -18,14 +18,16 @@ if(USE_TD_MEMORY)
|
|||
add_definitions(-DUSE_TD_MEMORY)
|
||||
endif ()
|
||||
if(BUILD_ADDR2LINE)
|
||||
target_include_directories(
|
||||
os
|
||||
PUBLIC "${TD_SOURCE_DIR}/contrib/libdwarf/src/lib/libdwarf"
|
||||
)
|
||||
if(NOT TD_WINDOWS)
|
||||
target_include_directories(
|
||||
os
|
||||
PUBLIC "${TD_SOURCE_DIR}/contrib/libdwarf/src/lib/libdwarf"
|
||||
)
|
||||
target_link_libraries(
|
||||
os PUBLIC addr2line dl z
|
||||
)
|
||||
endif()
|
||||
add_definitions(-DUSE_ADDR2LINE)
|
||||
target_link_libraries(
|
||||
os PUBLIC addr2line dl z
|
||||
)
|
||||
endif ()
|
||||
if(CHECK_STR2INT_ERROR)
|
||||
add_definitions(-DTD_CHECK_STR_TO_INT_ERROR)
|
||||
|
|
|
@ -91,7 +91,12 @@ void taosRemoveDir(const char *dirname) {
|
|||
bool taosDirExist(const char *dirname) { return taosCheckExistFile(dirname); }
|
||||
|
||||
int32_t taosMkDir(const char *dirname) {
|
||||
if (taosDirExist(dirname)) return 0;
|
||||
#ifdef WINDOWS
|
||||
int32_t code = _mkdir(dirname, 0755);
|
||||
#else
|
||||
int32_t code = mkdir(dirname, 0755);
|
||||
#endif
|
||||
if (code < 0 && errno == EEXIST) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -101,36 +106,48 @@ int32_t taosMkDir(const char *dirname) {
|
|||
|
||||
int32_t taosMulMkDir(const char *dirname) {
|
||||
if (dirname == NULL) return -1;
|
||||
char * temp = strdup(dirname);
|
||||
char temp[1024];
|
||||
#ifdef WINDOWS
|
||||
taosRealPath(dirname, temp, sizeof(temp));
|
||||
#else
|
||||
strcpy(temp, dirname);
|
||||
#endif
|
||||
char * pos = temp;
|
||||
int32_t code = 0;
|
||||
|
||||
if (strncmp(temp, "/", 1) == 0) {
|
||||
if (taosDirExist(temp)) return code;
|
||||
|
||||
if (strncmp(temp, TD_DIRSEP, 1) == 0) {
|
||||
pos += 1;
|
||||
} else if (strncmp(temp, "./", 2) == 0) {
|
||||
} else if (strncmp(temp, "." TD_DIRSEP, 2) == 0) {
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
for (; *pos != '\0'; pos++) {
|
||||
if (*pos == '/') {
|
||||
if (*pos == TD_DIRSEP[0]) {
|
||||
*pos = '\0';
|
||||
#ifdef WINDOWS
|
||||
code = _mkdir(temp, 0755);
|
||||
#else
|
||||
code = mkdir(temp, 0755);
|
||||
#endif
|
||||
if (code < 0 && errno != EEXIST) {
|
||||
free(temp);
|
||||
return code;
|
||||
}
|
||||
*pos = '/';
|
||||
*pos = TD_DIRSEP[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (*(pos - 1) != '/') {
|
||||
if (*(pos - 1) != TD_DIRSEP[0]) {
|
||||
#ifdef WINDOWS
|
||||
code = _mkdir(temp, 0755);
|
||||
#else
|
||||
code = mkdir(temp, 0755);
|
||||
#endif
|
||||
if (code < 0 && errno != EEXIST) {
|
||||
free(temp);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
free(temp);
|
||||
|
||||
// int32_t code = mkdir(dirname, 0755);
|
||||
if (code < 0 && errno == EEXIST) {
|
||||
|
@ -233,7 +250,13 @@ char *taosDirName(char *name) {
|
|||
_splitpath(name, Drive1, Dir1, NULL, NULL);
|
||||
size_t dirNameLen = strlen(Drive1) + strlen(Dir1);
|
||||
if (dirNameLen > 0) {
|
||||
name[dirNameLen] = 0;
|
||||
if (name[dirNameLen - 1] == '/' || name[dirNameLen - 1] == '\\') {
|
||||
name[dirNameLen - 1] = 0;
|
||||
} else {
|
||||
name[dirNameLen] = 0;
|
||||
}
|
||||
} else {
|
||||
name[0] = 0;
|
||||
}
|
||||
return name;
|
||||
#else
|
||||
|
|
|
@ -109,8 +109,11 @@ void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, cha
|
|||
|
||||
int64_t taosCopyFile(const char *from, const char *to) {
|
||||
#ifdef WINDOWS
|
||||
assert(0);
|
||||
return -1;
|
||||
if (CopyFile(from, to, 0)) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
char buffer[4096];
|
||||
int64_t size = 0;
|
||||
|
@ -236,7 +239,7 @@ int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno) {
|
|||
|
||||
void autoDelFileListAdd(const char *path) { return; }
|
||||
|
||||
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||
int fd = -1;
|
||||
FILE *fp = NULL;
|
||||
if (tdFileOptions & TD_FILE_STREAM) {
|
||||
|
@ -343,7 +346,11 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
|
|||
char *tbuf = (char *)buf;
|
||||
|
||||
while (leftbytes > 0) {
|
||||
#ifdef WINDOWS
|
||||
readbytes = _read(pFile->fd, (void *)tbuf, (uint32_t)leftbytes);
|
||||
#else
|
||||
readbytes = read(pFile->fd, (void *)tbuf, (uint32_t)leftbytes);
|
||||
#endif
|
||||
if (readbytes < 0) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
|
@ -379,10 +386,10 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
|
|||
#endif
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
#ifdef WINDOWS
|
||||
size_t pos = lseek(pFile->fd, 0, SEEK_CUR);
|
||||
lseek(pFile->fd, offset, SEEK_SET);
|
||||
int64_t ret = read(pFile->fd, buf, count);
|
||||
lseek(pFile->fd, pos, SEEK_SET);
|
||||
size_t pos = _lseek(pFile->fd, 0, SEEK_CUR);
|
||||
_lseek(pFile->fd, offset, SEEK_SET);
|
||||
int64_t ret = _read(pFile->fd, buf, count);
|
||||
_lseek(pFile->fd, pos, SEEK_SET);
|
||||
#else
|
||||
int64_t ret = pread(pFile->fd, buf, count, offset);
|
||||
#endif
|
||||
|
@ -428,7 +435,11 @@ int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
|||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||
#endif
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
#ifdef WINDOWS
|
||||
int64_t ret = _lseek(pFile->fd, offset, whence);
|
||||
#else
|
||||
int64_t ret = lseek(pFile->fd, offset, whence);
|
||||
#endif
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||
#endif
|
||||
|
@ -567,12 +578,12 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
|||
|
||||
#ifdef WINDOWS
|
||||
|
||||
lseek(pFileIn->fd, (int32_t)(*offset), 0);
|
||||
_lseek(pFileIn->fd, (int32_t)(*offset), 0);
|
||||
int64_t writeLen = 0;
|
||||
uint8_t buffer[_SEND_FILE_STEP_] = {0};
|
||||
|
||||
for (int64_t len = 0; len < (size - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
|
||||
size_t rlen = read(pFileIn->fd, (void *)buffer, _SEND_FILE_STEP_);
|
||||
size_t rlen = _read(pFileIn->fd, (void *)buffer, _SEND_FILE_STEP_);
|
||||
if (rlen <= 0) {
|
||||
return writeLen;
|
||||
} else if (rlen < _SEND_FILE_STEP_) {
|
||||
|
@ -586,7 +597,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
|||
|
||||
int64_t remain = size - writeLen;
|
||||
if (remain > 0) {
|
||||
size_t rlen = read(pFileIn->fd, (void *)buffer, (size_t)remain);
|
||||
size_t rlen = _read(pFileIn->fd, (void *)buffer, (size_t)remain);
|
||||
if (rlen <= 0) {
|
||||
return writeLen;
|
||||
} else {
|
||||
|
|
|
@ -37,6 +37,49 @@ typedef struct TdMemoryInfo {
|
|||
|
||||
#ifdef WINDOWS
|
||||
#define tstrdup(str) _strdup(str)
|
||||
|
||||
int32_t taosBackTrace(void **buffer, int32_t size) {
|
||||
int32_t frame = 0;
|
||||
return frame;
|
||||
}
|
||||
|
||||
#ifdef USE_ADDR2LINE
|
||||
#include <DbgHelp.h>
|
||||
#pragma comment(lib, "dbghelp.lib")
|
||||
|
||||
void taosPrintBackTrace() {
|
||||
#define MAX_STACK_FRAMES 20
|
||||
|
||||
void *pStack[MAX_STACK_FRAMES];
|
||||
|
||||
HANDLE process = GetCurrentProcess();
|
||||
SymInitialize(process, NULL, TRUE);
|
||||
WORD frames = CaptureStackBackTrace(1, MAX_STACK_FRAMES, pStack, NULL);
|
||||
|
||||
char buf_tmp[1024];
|
||||
for (WORD i = 0; i < frames; ++i) {
|
||||
DWORD64 address = (DWORD64)(pStack[i]);
|
||||
|
||||
DWORD64 displacementSym = 0;
|
||||
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
|
||||
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
|
||||
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
pSymbol->MaxNameLen = MAX_SYM_NAME;
|
||||
|
||||
DWORD displacementLine = 0;
|
||||
IMAGEHLP_LINE64 line;
|
||||
//SymSetOptions(SYMOPT_LOAD_LINES);
|
||||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||
|
||||
if (SymFromAddr(process, address, &displacementSym, pSymbol) && SymGetLineFromAddr64(process, address, &displacementLine, &line)) {
|
||||
snprintf(buf_tmp,sizeof(buf_tmp),"BackTrace %08" PRId64 " %s:%d %s\n", taosGetSelfPthreadId(), line.FileName, line.LineNumber, pSymbol->Name);
|
||||
} else {
|
||||
snprintf(buf_tmp,sizeof(buf_tmp),"BackTrace error: %d\n",GetLastError());
|
||||
}
|
||||
write(1,buf_tmp,strlen(buf_tmp));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define tstrdup(str) strdup(str)
|
||||
|
||||
|
|
|
@ -68,9 +68,32 @@ int32_t tsem_wait(tsem_t* sem) {
|
|||
}
|
||||
|
||||
int32_t tsem_timewait(tsem_t* sem, int64_t nanosecs) {
|
||||
int ret = 0;
|
||||
struct timespec ts, rel;
|
||||
FILETIME ft_before, ft_after;
|
||||
int rc;
|
||||
|
||||
return ret;
|
||||
rel.tv_sec = 0;
|
||||
rel.tv_nsec = nanosecs;
|
||||
|
||||
GetSystemTimeAsFileTime(&ft_before);
|
||||
errno = 0;
|
||||
rc = sem_timedwait(&sem, pthread_win32_getabstime_np(&ts, &rel));
|
||||
|
||||
/* This should have timed out */
|
||||
assert(errno == ETIMEDOUT);
|
||||
assert(rc != 0);
|
||||
GetSystemTimeAsFileTime(&ft_after);
|
||||
// We specified a non-zero wait. Time must advance.
|
||||
if (ft_before.dwLowDateTime == ft_after.dwLowDateTime && ft_before.dwHighDateTime == ft_after.dwHighDateTime)
|
||||
{
|
||||
printf("nanoseconds: %d, rc: %d, errno: %d. before filetime: %d, %d; after filetime: %d, %d\n",
|
||||
nanosecs, rc, errno,
|
||||
(int)ft_before.dwLowDateTime, (int)ft_before.dwHighDateTime,
|
||||
(int)ft_after.dwLowDateTime, (int)ft_after.dwHighDateTime);
|
||||
printf("time must advance during sem_timedwait.");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
|
|
|
@ -718,7 +718,11 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
|
|||
|
||||
bzero((char *)&serverAdd, sizeof(serverAdd));
|
||||
serverAdd.sin_family = AF_INET;
|
||||
#ifdef WINDOWS
|
||||
serverAdd.sin_addr.s_addr = INADDR_ANY;
|
||||
#else
|
||||
serverAdd.sin_addr.s_addr = ip;
|
||||
#endif
|
||||
serverAdd.sin_port = (uint16_t)htons(port);
|
||||
|
||||
if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) <= 2) {
|
||||
|
@ -882,6 +886,16 @@ void taosBlockSIGPIPE() {
|
|||
}
|
||||
|
||||
uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
|
||||
#ifdef WINDOWS
|
||||
// Initialize Winsock
|
||||
WSADATA wsaData;
|
||||
int iResult;
|
||||
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (iResult != 0) {
|
||||
printf("WSAStartup failed: %d\n", iResult);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
struct addrinfo hints = {0};
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
@ -899,12 +913,12 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
|
|||
} else {
|
||||
#ifdef EAI_SYSTEM
|
||||
if (ret == EAI_SYSTEM) {
|
||||
// printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, strerror(errno));
|
||||
printf("failed to get the ip address, fqdn:%s, errno:%d, since:%s", fqdn, errno, strerror(errno));
|
||||
} else {
|
||||
// printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
|
||||
printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret));
|
||||
}
|
||||
#else
|
||||
// printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
|
||||
printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret));
|
||||
#endif
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 772aef458fec13804c654e59c7a248b55ba3807b
|
||||
Subproject commit 788929bdc475d264d8306ceff30f7df006fd18d8
|
Loading…
Reference in New Issue