提交 88780e30 编写于 作者: S slguan

issue #399

上级 977550a1
......@@ -63,4 +63,6 @@ void taosGetSystemInfo();
void taosKillSystem();
bool taosIsRunningWSLv1();
#endif
\ No newline at end of file
......@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <sys/utsname.h>
#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
......@@ -124,6 +124,8 @@ int sigaction(int, struct sigaction *, void *);
void sleep(int mseconds);
bool taosIsRunningWSLv1();
#ifdef __cplusplus
}
#endif
......
......@@ -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;
}
......@@ -23,17 +23,14 @@
#include <pthread.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/utsname.h>
#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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册