diff --git a/src/net/AresHandler.cxx b/src/net/AresHandler.cxx index ac56a5a21a..d5d4f28987 100644 --- a/src/net/AresHandler.cxx +++ b/src/net/AresHandler.cxx @@ -163,19 +163,25 @@ void AresHandler::callback(int callbackStatus, struct hostent *hostent) const char *AresHandler::getHostname() { - const std::lock_guard lock(callback_mutex); - - return hostName.c_str(); + if (!callback_mutex.try_lock()) + return ""; + const char *host = hostName.c_str(); + callback_mutex.unlock(); + return host; } AresHandler::ResolutionStatus AresHandler::getHostAddress(struct in_addr *clientAddr) { - const std::lock_guard lock(callback_mutex); + if (!callback_mutex.try_lock()) + return HbNPending; + const ResolutionStatus oldStatus = status; if (status == HbNSucceeded) memcpy(clientAddr, &hostAddress, sizeof(hostAddress)); - return status; + callback_mutex.unlock(); + + return oldStatus; } #if ARES_VERSION_MAJOR > 1 || ARES_VERSION_MINOR >= 26