commit
38ce98fd58
|
@ -493,7 +493,7 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort,
|
||||||
SRpcConn *pConn;
|
SRpcConn *pConn;
|
||||||
|
|
||||||
uint32_t peerIp = taosGetIpFromFqdn(peerFqdn);
|
uint32_t peerIp = taosGetIpFromFqdn(peerFqdn);
|
||||||
if (peerIp == -1) {
|
if (peerIp == 0xFFFFFFFF) {
|
||||||
tError("%s, failed to resolve FQDN:%s", pRpc->label, peerFqdn);
|
tError("%s, failed to resolve FQDN:%s", pRpc->label, peerFqdn);
|
||||||
terrno = TSDB_CODE_RPC_APP_ERROR;
|
terrno = TSDB_CODE_RPC_APP_ERROR;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -29,11 +29,12 @@ int taosGetFqdn(char *fqdn) {
|
||||||
|
|
||||||
hints.ai_flags = AI_CANONNAME;
|
hints.ai_flags = AI_CANONNAME;
|
||||||
|
|
||||||
getaddrinfo(hostname, NULL, &hints, &result);
|
int32_t ret = getaddrinfo(hostname, NULL, &hints, &result);
|
||||||
if (result) {
|
if (result) {
|
||||||
strcpy(fqdn, result->ai_canonname);
|
strcpy(fqdn, result->ai_canonname);
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
} else {
|
} else {
|
||||||
|
uError("failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret));
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,9 +43,12 @@ int taosGetFqdn(char *fqdn) {
|
||||||
|
|
||||||
uint32_t taosGetIpFromFqdn(const char *fqdn) {
|
uint32_t taosGetIpFromFqdn(const char *fqdn) {
|
||||||
struct addrinfo hints = {0};
|
struct addrinfo hints = {0};
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
struct addrinfo *result = NULL;
|
struct addrinfo *result = NULL;
|
||||||
|
|
||||||
getaddrinfo(fqdn, NULL, &hints, &result);
|
int32_t ret = getaddrinfo(fqdn, NULL, &hints, &result);
|
||||||
if (result) {
|
if (result) {
|
||||||
struct sockaddr *sa = result->ai_addr;
|
struct sockaddr *sa = result->ai_addr;
|
||||||
struct sockaddr_in *si = (struct sockaddr_in*)sa;
|
struct sockaddr_in *si = (struct sockaddr_in*)sa;
|
||||||
|
@ -53,7 +57,8 @@ uint32_t taosGetIpFromFqdn(const char *fqdn) {
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
return ip;
|
return ip;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
uError("failed get the ip address, fqdn:%s, code:%d, reason:%s", fqdn, ret, gai_strerror(ret));
|
||||||
|
return 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue