add perf log to blocking-sys-call

This commit is contained in:
yihaoDeng 2024-12-06 15:08:59 +08:00
parent 59ae3f18f6
commit 8c128ca05d
1 changed files with 19 additions and 9 deletions

View File

@ -233,15 +233,19 @@ int32_t taosBlockSIGPIPE() {
}
int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
int32_t code = 0;
OS_PARAM_CHECK(fqdn);
OS_PARAM_CHECK(ip);
int64_t limitMs = 1000;
int64_t st = taosGetTimestampMs(), cost = 0;
#ifdef WINDOWS
// Initialize Winsock
WSADATA wsaData;
int iResult;
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != 0) {
return TAOS_SYSTEM_WINSOCKET_ERROR(WSAGetLastError());
code = TAOS_SYSTEM_WINSOCKET_ERROR(WSAGetLastError());
goto _err;
}
#endif
@ -260,12 +264,12 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
inRetry = true;
continue;
} else if (EAI_SYSTEM == ret) {
terrno = TAOS_SYSTEM_ERROR(errno);
return terrno;
code = TAOS_SYSTEM_ERROR(errno);
goto _err;
}
terrno = TAOS_SYSTEM_ERROR(errno);
return terrno;
code = TAOS_SYSTEM_ERROR(errno);
goto _err;
}
struct sockaddr *sa = result->ai_addr;
@ -275,8 +279,7 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
*ip = ia.s_addr;
freeaddrinfo(result);
return 0;
goto _err;
}
#else
struct addrinfo hints = {0};
@ -292,7 +295,7 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
struct in_addr ia = si->sin_addr;
*ip = ia.s_addr;
freeaddrinfo(result);
return 0;
goto _err;
} else {
#ifdef EAI_SYSTEM
if (ret == EAI_SYSTEM) {
@ -305,9 +308,16 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) {
#endif
*ip = 0xFFFFFFFF;
return TSDB_CODE_RPC_FQDN_ERROR;
code = TSDB_CODE_RPC_FQDN_ERROR;
goto _err;
}
#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) {