fix(os): fix a deadlock.

This commit is contained in:
Haojun Liao 2023-04-19 14:08:41 +08:00
parent fb32ffd960
commit 9fb7589fb5
2 changed files with 6 additions and 4 deletions

View File

@ -1008,7 +1008,7 @@ int32_t taosGetFqdn(char *fqdn) {
// hints.ai_family = AF_INET;
strcpy(fqdn, hostname);
strcpy(fqdn + strlen(hostname), ".local");
#else // __APPLE__
#else // linux
struct addrinfo hints = {0};
struct addrinfo *result = NULL;
hints.ai_flags = AI_CANONNAME;
@ -1020,7 +1020,7 @@ int32_t taosGetFqdn(char *fqdn) {
}
strcpy(fqdn, result->ai_canonname);
freeaddrinfo(result);
#endif // __APPLE__
#endif // linux
return 0;
}

View File

@ -791,8 +791,10 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t
tjsonAddIntegerToObject(pJson, "clusterId", clusterId);
tjsonAddIntegerToObject(pJson, "startTime", startTime);
taosGetFqdn(tmp);
tjsonAddStringToObject(pJson, "fqdn", tmp);
// Do NOT invoke the taosGetFqdn here.
// this function may be invoked when memory exception occurs,so we should assume that it is running in a memory locked
// environment. The lock operation by taosGetFqdn may cause this program deadlock.
tjsonAddStringToObject(pJson, "fqdn", tsLocalFqdn);
tjsonAddIntegerToObject(pJson, "pid", taosGetPId());