summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qpid/sys/posix
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2012-07-10 19:22:54 +0000
committerGordon Sim <gsim@apache.org>2012-07-10 19:22:54 +0000
commitb3d7201e4b8989ff32ce37b30886e4c77af98141 (patch)
tree7dc9685d473b0edfe39879c2f38b497c771af3ed /qpid/cpp/src/qpid/sys/posix
parent75a570de0545d7900392819ea0bb93e05c738ef6 (diff)
downloadqpid-python-b3d7201e4b8989ff32ce37b30886e4c77af98141.tar.gz
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
Diffstat (limited to 'qpid/cpp/src/qpid/sys/posix')
-rwxr-xr-xqpid/cpp/src/qpid/sys/posix/SystemInfo.cpp6
1 files changed, 5 insertions, 1 deletions
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 <fstream>
#include <sstream>
#include <netdb.h>
+#include <string.h>
#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); }