Merge pull request #29056 from taosdata/enh/addPerfLog
add perf log to blocking-sys-call
This commit is contained in:
commit
ca66bc0885
|
@ -233,15 +233,19 @@ int32_t taosBlockSIGPIPE() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
|
int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
|
||||||
|
int32_t code = 0;
|
||||||
OS_PARAM_CHECK(fqdn);
|
OS_PARAM_CHECK(fqdn);
|
||||||
OS_PARAM_CHECK(ip);
|
OS_PARAM_CHECK(ip);
|
||||||
|
int64_t limitMs = 1000;
|
||||||
|
int64_t st = taosGetTimestampMs(), cost = 0;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
// Initialize Winsock
|
// Initialize Winsock
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
int iResult;
|
int iResult;
|
||||||
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||||
if (iResult != 0) {
|
if (iResult != 0) {
|
||||||
return TAOS_SYSTEM_WINSOCKET_ERROR(WSAGetLastError());
|
code = TAOS_SYSTEM_WINSOCKET_ERROR(WSAGetLastError());
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -260,12 +264,12 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
|
||||||
inRetry = true;
|
inRetry = true;
|
||||||
continue;
|
continue;
|
||||||
} else if (EAI_SYSTEM == ret) {
|
} else if (EAI_SYSTEM == ret) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
return terrno;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
return terrno;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr *sa = result->ai_addr;
|
struct sockaddr *sa = result->ai_addr;
|
||||||
|
@ -275,8 +279,7 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
|
||||||
*ip = ia.s_addr;
|
*ip = ia.s_addr;
|
||||||
|
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
|
goto _err;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
struct addrinfo hints = {0};
|
struct addrinfo hints = {0};
|
||||||
|
@ -292,7 +295,7 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
|
||||||
struct in_addr ia = si->sin_addr;
|
struct in_addr ia = si->sin_addr;
|
||||||
*ip = ia.s_addr;
|
*ip = ia.s_addr;
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
return 0;
|
goto _err;
|
||||||
} else {
|
} else {
|
||||||
#ifdef EAI_SYSTEM
|
#ifdef EAI_SYSTEM
|
||||||
if (ret == EAI_SYSTEM) {
|
if (ret == EAI_SYSTEM) {
|
||||||
|
@ -305,9 +308,16 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*ip = 0xFFFFFFFF;
|
*ip = 0xFFFFFFFF;
|
||||||
return TSDB_CODE_RPC_FQDN_ERROR;
|
code = TSDB_CODE_RPC_FQDN_ERROR;
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
_err:
|
||||||
|
cost = taosGetTimestampMs() - st;
|
||||||
|
if (cost >= limitMs) {
|
||||||
|
uWarn("get ip from fqdn:%s, cost:%" PRId64 "ms", fqdn, cost);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosGetFqdn(char *fqdn) {
|
int32_t taosGetFqdn(char *fqdn) {
|
||||||
|
|
Loading…
Reference in New Issue