From f0b9784570ff1337cd787beab8220ae02537fb11 Mon Sep 17 00:00:00 2001 From: David Zarzycki Date: Wed, 11 Sep 2019 08:32:37 +0000 Subject: [LLDB] Do not try to canonicalize gethostname() result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This code is trying too hard and failing. Either the result of gethostname() is canonical or it is not. If it is not, then trying to canonicalize it is – for various reasons – a lost cause. For example, a given machine might have multiple network interfaces with multiple addresses per interface, each with a different canonical name. Separably, the result of HostInfoPosix::GetHostname() and latency thereof shouldn't depend on whether networking is up or down or what network the machine happened to be attached to at any given moment (like a laptop that travels between work and home). https://reviews.llvm.org/D67230 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@371596 91177308-0d34-0410-b5e6-96231b3b80d8 --- source/Host/posix/HostInfoPosix.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'source/Host') diff --git a/source/Host/posix/HostInfoPosix.cpp b/source/Host/posix/HostInfoPosix.cpp index 78300fca0..e7d0deef3 100644 --- a/source/Host/posix/HostInfoPosix.cpp +++ b/source/Host/posix/HostInfoPosix.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -32,17 +31,7 @@ bool HostInfoPosix::GetHostname(std::string &s) { char hostname[PATH_MAX]; hostname[sizeof(hostname) - 1] = '\0'; if (::gethostname(hostname, sizeof(hostname) - 1) == 0) { - struct addrinfo hints; - struct addrinfo *res = nullptr; - std::memset(&hints, 0, sizeof(hints)); - hints.ai_flags = AI_CANONNAME; - int err = ::getaddrinfo(hostname, nullptr, &hints, &res); - if (err == 0) { - assert(res->ai_canonname && "getaddrinfo found a canonical name"); - s.assign(res->ai_canonname); - freeaddrinfo(res); - } else - s.assign(hostname); + s.assign(hostname); return true; } return false; -- cgit v1.2.3