Merge pull request #23919 from taosdata/fix/xsren/TD-27561/fqdnFailedMsg

fix error msg if failed get ip from fqdn
This commit is contained in:
dapan1121 2023-12-04 15:17:17 +08:00 committed by GitHub
commit aa4efa0595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 2 deletions

View File

@ -1282,7 +1282,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
static int32_t taosCheckGlobalCfg() {
uint32_t ipv4 = taosGetIpv4FromFqdn(tsLocalFqdn);
if (ipv4 == 0xffffffff) {
terrno = TAOS_SYSTEM_ERROR(errno);
terrno = TSDB_CODE_RPC_FQDN_ERROR;
uError("failed to get ip from fqdn:%s since %s, dnode can not be initialized", tsLocalFqdn, terrstr());
return -1;
}

View File

@ -1468,7 +1468,7 @@ static FORCE_INLINE uint32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn)
if (v == NULL) {
addr = taosGetIpv4FromFqdn(fqdn);
if (addr == 0xffffffff) {
terrno = TAOS_SYSTEM_ERROR(errno);
terrno = TSDB_CODE_RPC_FQDN_ERROR;
tError("failed to get ip from fqdn:%s since %s", fqdn, terrstr());
return addr;
}

View File

@ -32,6 +32,35 @@
#ifdef WINDOWS
#include <windows.h>
#else
#include <arpa/inet.h>
TEST(osTest, osFQDNSuccess) {
char fqdn[1024];
char ipString[INET_ADDRSTRLEN];
int code = taosGetFqdn(fqdn);
uint32_t ipv4 = taosGetIpv4FromFqdn(fqdn);
ASSERT_NE(ipv4, 0xffffffff);
struct in_addr addr;
addr.s_addr = htonl(ipv4);
snprintf(ipString, INET_ADDRSTRLEN, "%u.%u.%u.%u", (unsigned int)(addr.s_addr >> 24) & 0xFF,
(unsigned int)(addr.s_addr >> 16) & 0xFF, (unsigned int)(addr.s_addr >> 8) & 0xFF,
(unsigned int)(addr.s_addr) & 0xFF);
printf("fqdn:%s ip:%s\n", fqdn, ipString);
}
TEST(osTest, osFQDNFailed) {
char fqdn[1024] = "fqdn_test_not_found";
char ipString[24];
uint32_t ipv4 = taosGetIpv4FromFqdn(fqdn);
ASSERT_EQ(ipv4, 0xffffffff);
terrno = TSDB_CODE_RPC_FQDN_ERROR;
printf("fqdn:%s transfer to ip failed!\n", fqdn);
}
#endif // WINDOWS
TEST(osTest, osSystem) {