diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index d12c5058cc..99950c54e5 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -14,6 +14,12 @@ */ #include "syncUtil.h" +#include +#include +#include +#include +#include + #include "syncEnv.h" void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port); @@ -22,7 +28,20 @@ void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port); uint64_t syncUtilAddr2U64(const char* host, uint16_t port) { uint64_t u64; uint32_t hostU32 = (uint32_t)taosInetAddr(host); - // assert(hostU32 != (uint32_t)-1); + if (hostU32 == (uint32_t)-1) { + struct hostent* hostEnt = gethostbyname(host); + if (hostEnt == NULL) { + sError("Get IP address error"); + return -1; + } + + const char* newHost = taosInetNtoa(*(struct in_addr*)(hostEnt->h_addr_list[0])); + hostU32 = (uint32_t)taosInetAddr(newHost); + if (hostU32 == (uint32_t)-1) { + sError("change %s to id, error", newHost); + } + // ASSERT(hostU32 != (uint32_t)-1); + } u64 = (((uint64_t)hostU32) << 32) | (((uint32_t)port) << 16); return u64; }