diff --git a/src/os/linux/inc/os.h b/src/os/linux/inc/os.h index f1b62d147c323f81006f68e1309dbb02b7af15f2..002d0be4ca7a97d2cd32a983cc644b7af1c80b07 100644 --- a/src/os/linux/inc/os.h +++ b/src/os/linux/inc/os.h @@ -63,4 +63,6 @@ void taosGetSystemInfo(); void taosKillSystem(); +bool taosIsRunningWSLv1(); + #endif \ No newline at end of file diff --git a/src/os/linux/src/os.c b/src/os/linux/src/os.c index 7b6be057c801f6b9be5d48d82b4772514815bd5f..d65e78e3a4e0143cd10aa445621f35328712976b 100644 --- a/src/os/linux/src/os.c +++ b/src/os/linux/src/os.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "tglobalcfg.h" #include "tlog.h" @@ -293,4 +294,20 @@ ssize_t twrite(int fd, void *buf, size_t n) { } return n; +} + +// check if the linux running is WSL +bool taosIsRunningWSLv1() { + struct utsname buf; + if (uname(&buf)) { + pPrint(" can't fetch os info"); + return false; + } + + if (strstr(buf.release, "Microsoft") != 0) { + pPrint(" using WSLv1"); + return true; + } + + return false; } \ No newline at end of file diff --git a/src/os/windows/inc/os.h b/src/os/windows/inc/os.h index 81a33141abba8a9dffd53be7b82a6fb4a7ba6a90..7d354bf4929399b14f07c8095307fce96b56786e 100644 --- a/src/os/windows/inc/os.h +++ b/src/os/windows/inc/os.h @@ -124,6 +124,8 @@ int sigaction(int, struct sigaction *, void *); void sleep(int mseconds); +bool taosIsRunningWSLv1(); + #ifdef __cplusplus } #endif diff --git a/src/os/windows/src/twindows.c b/src/os/windows/src/twindows.c index 91cc560eb97bad419733b2d28d87bf2d435e242a..deda1b40dc8a5123c13f53b5783c0d77d54da1da 100644 --- a/src/os/windows/src/twindows.c +++ b/src/os/windows/src/twindows.c @@ -196,4 +196,7 @@ int wordexp(const char *words, wordexp_t *pwordexp, int flags) { void wordfree(wordexp_t *pwordexp) {} void taosGetDisk() {} +bool taosIsRunningWSLv1() { + return false; +} diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index fe7233feece0528659e0cd4c474edc4cc87ca793..04b59a25086abab54ac9f66f7c1ea59c3f6becb0 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -23,17 +23,14 @@ #include #include #include -#include #include "os.h" #include "tglobalcfg.h" #include "tlog.h" #include "tsocket.h" #include "tutil.h" -#include "tsystem.h" unsigned int ip2uint(const char *const ip_addr); -bool isRunningWSLv1(); /* * Function to get the public ip address of current machine. If get IP @@ -306,7 +303,7 @@ int taosOpenUdpSocket(char *ip, short port) { if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_NO_CHECK, (void *)&nocheck, sizeof(nocheck)) < 0) { // no_check is not implemented in WSL // skip the following check if system running WSLv1 - if (!isRunningWSLv1()) { + if (!taosIsRunningWSLv1()) { pError("setsockopt SO_NO_CHECK failed: %d (%s)", errno, strerror(errno)); close(sockFd); return -1; @@ -556,19 +553,3 @@ int taosCopyFds(int sfd, int dfd, int64_t len) { return 0; } - -// check if the linux running is WSL -bool isRunningWSLv1() { - struct utsname buf; - if (uname(&buf)) { - pPrint(" can't fetch os info"); - return false; - } - - if (strstr(buf.release, "Microsoft") != 0) { - pPrint(" using WSLv1"); - return true; - } - - return false; -} \ No newline at end of file