From 2239a924f04ed617133b08b9eace2fbb0dc4136c Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 29 Jul 2024 16:14:52 +0800 Subject: [PATCH] enh: return code of get ip from fqdn --- source/os/src/osSocket.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 1b0deb1819..f9ae6c2157 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -941,7 +941,7 @@ int32_t taosBlockSIGPIPE() { #endif } -int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip) { +int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) { #ifdef WINDOWS // Initialize Winsock WSADATA wsaData; @@ -959,8 +959,8 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip) { hints.ai_socktype = SOCK_STREAM; struct addrinfo *result = NULL; - bool inRetry = false; - + bool inRetry = false; + while (true) { int32_t ret = getaddrinfo(fqdn, NULL, &hints, &result); if (ret) { @@ -972,7 +972,7 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip) { return terrno; } - terrno = TAOS_SYSTEM_ERROR(ret); + terrno = TAOS_SYSTEM_ERROR(errno); return terrno; } @@ -1011,7 +1011,7 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip) { #else // printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret)); #endif - + *ip = 0xFFFFFFFF; return 0xFFFFFFFF; }