diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index a7fd6de844065f0c07e368ebb4d086f5de3402af..fe7233feece0528659e0cd4c474edc4cc87ca793 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -23,14 +23,17 @@ #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 @@ -301,9 +304,15 @@ int taosOpenUdpSocket(char *ip, short port) { nocheck = 1; if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_NO_CHECK, (void *)&nocheck, sizeof(nocheck)) < 0) { - pError("setsockopt SO_NO_CHECK failed: %d (%s)", errno, strerror(errno)); - close(sockFd); - return -1; + // no_check is not implemented in WSL + // skip the following check if system running WSLv1 + if (!isRunningWSLv1()) { + pError("setsockopt SO_NO_CHECK failed: %d (%s)", errno, strerror(errno)); + close(sockFd); + return -1; + } else { + pError("Skipping: setsockopt SO_NO_CHECK failed: %d (%s)", errno, strerror(errno)); + } } ttl = 128; @@ -547,3 +556,19 @@ 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