From 1a18c1798833e7201177e786afa0d05412c4f53b Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 12 Nov 2008 15:42:24 +0000 Subject: Fix problem where broker generates empty URL if run on a host with only the 127.0.0.1 loopback interface. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@713405 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/posix/SystemInfo.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/sys/posix/SystemInfo.cpp b/cpp/src/qpid/sys/posix/SystemInfo.cpp index c054931a96..9bbd023e29 100755 --- a/cpp/src/qpid/sys/posix/SystemInfo.cpp +++ b/cpp/src/qpid/sys/posix/SystemInfo.cpp @@ -53,11 +53,10 @@ bool SystemInfo::getLocalHostname (TcpAddress &address) { return true; } +static const string LOCALHOST("127.0.0.1"); + void SystemInfo::getLocalIpAddresses (uint16_t port, std::vector
&addrList) { - - static const string LOCALHOST("127.0.0.1"); - int s = socket (PF_INET, SOCK_STREAM, 0); for (int i=1;;i++) { struct ifreq ifr; @@ -72,6 +71,9 @@ void SystemInfo::getLocalIpAddresses (uint16_t port, if (addr != LOCALHOST) addrList.push_back(TcpAddress(addr, port)); } + if (addrList.empty()) { + addrList.push_back(TcpAddress(LOCALHOST, port)); + } close (s); } -- cgit v1.2.1