issue #399
This commit is contained in:
parent
977550a1df
commit
88780e3096
|
@ -63,4 +63,6 @@ void taosGetSystemInfo();
|
|||
|
||||
void taosKillSystem();
|
||||
|
||||
bool taosIsRunningWSLv1();
|
||||
|
||||
#endif
|
|
@ -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"
|
||||
|
@ -294,3 +295,19 @@ 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;
|
||||
}
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue