From 6c316d204f7c2f07f6e9c21e554d1be8991bad2d Mon Sep 17 00:00:00 2001 From: Zimeng Pan Date: Mon, 12 Aug 2019 23:40:12 -0700 Subject: [PATCH] temporary fix for WSLv1 --- src/util/src/tsocket.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index a7fd6de844..fe7233feec 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 -- GitLab