From b3d7201e4b8989ff32ce37b30886e4c77af98141 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 10 Jul 2012 19:22:54 +0000 Subject: QPID-4127: Ensure SystemInfo::isLocalHost() returns true for ::1 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1359855 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp b/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp index 007d0773fc..2b1bbb97df 100755 --- a/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp +++ b/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #ifndef HOST_NAME_MAX # define HOST_NAME_MAX 256 @@ -125,7 +126,10 @@ namespace { struct AddrInfo { struct addrinfo* ptr; AddrInfo(const std::string& host) : ptr(0) { - if (::getaddrinfo(host.c_str(), NULL, NULL, &ptr) != 0) + ::addrinfo hints; + ::memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; // Allow both IPv4 and IPv6 + if (::getaddrinfo(host.c_str(), NULL, &hints, &ptr) != 0) ptr = 0; } ~AddrInfo() { if (ptr) ::freeaddrinfo(ptr); } -- cgit v1.2.1