Merge pull request #2402 from taosdata/feature/sangshuduo/cleanup-os-ununsed-functions
remove unused os-specified functions.
This commit is contained in:
commit
49f625cdbd
|
@ -56,70 +56,8 @@ void taosMsleep(int mseconds) {
|
||||||
|
|
||||||
bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; }
|
bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; }
|
||||||
|
|
||||||
void taosResetPthread(pthread_t *thread) { *thread = 0; }
|
|
||||||
|
|
||||||
int64_t taosGetPthreadId() { return (int64_t)pthread_self(); }
|
int64_t taosGetPthreadId() { return (int64_t)pthread_self(); }
|
||||||
|
|
||||||
/*
|
|
||||||
* Function to get the private ip address of current machine. If get IP
|
|
||||||
* successfully, return 0, else, return -1. The return values is ip.
|
|
||||||
*
|
|
||||||
* Use:
|
|
||||||
* if (taosGetPrivateIp(ip) != 0) {
|
|
||||||
* perror("Fail to get private IP address\n");
|
|
||||||
* exit(EXIT_FAILURE);
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
int taosGetPrivateIp(char *const ip) {
|
|
||||||
bool hasLoCard = false;
|
|
||||||
|
|
||||||
struct ifaddrs *ifaddr, *ifa;
|
|
||||||
int family, s;
|
|
||||||
char host[NI_MAXHOST];
|
|
||||||
|
|
||||||
if (getifaddrs(&ifaddr) == -1) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Walk through linked list, maintaining head pointer so we can free list later */
|
|
||||||
int flag = 0;
|
|
||||||
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
|
|
||||||
if (ifa->ifa_addr == NULL) continue;
|
|
||||||
|
|
||||||
family = ifa->ifa_addr->sa_family;
|
|
||||||
if (strcmp("lo", ifa->ifa_name) == 0) {
|
|
||||||
hasLoCard = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (family == AF_INET) {
|
|
||||||
/* printf("%-8s", ifa->ifa_name); */
|
|
||||||
s = getnameinfo(ifa->ifa_addr, (family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6),
|
|
||||||
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
|
||||||
if (s != 0) {
|
|
||||||
freeifaddrs(ifaddr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(ip, host);
|
|
||||||
flag = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
freeifaddrs(ifaddr);
|
|
||||||
if (flag) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
if (hasLoCard) {
|
|
||||||
uPrint("no net card was found, use lo:127.0.0.1 as default");
|
|
||||||
strcpy(ip, "127.0.0.1");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int taosSetNonblocking(int sock, int on) {
|
int taosSetNonblocking(int sock, int on) {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if ((flags = fcntl(sock, F_GETFL, 0)) < 0) {
|
if ((flags = fcntl(sock, F_GETFL, 0)) < 0) {
|
||||||
|
@ -294,21 +232,6 @@ ssize_t twrite(int fd, void *buf, size_t n) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosSkipSocketCheck() {
|
|
||||||
struct utsname buf;
|
|
||||||
if (uname(&buf)) {
|
|
||||||
uPrint("can't fetch os info");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strstr(buf.release, "Microsoft") != 0) {
|
|
||||||
uPrint("using WSLv1");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosBlockSIGPIPE() {
|
void taosBlockSIGPIPE() {
|
||||||
sigset_t signal_mask;
|
sigset_t signal_mask;
|
||||||
sigemptyset(&signal_mask);
|
sigemptyset(&signal_mask);
|
||||||
|
|
Loading…
Reference in New Issue