diff options
author | Alan Conway <aconway@apache.org> | 2008-11-12 15:42:24 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-11-12 15:42:24 +0000 |
commit | 1a18c1798833e7201177e786afa0d05412c4f53b (patch) | |
tree | 8a5383b182fa01ba2c2077ba91b2ba985630a329 /cpp/src | |
parent | db2ca04e7a888289ac0f59537dcb6833cb7341da (diff) | |
download | qpid-python-1a18c1798833e7201177e786afa0d05412c4f53b.tar.gz |
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
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/qpid/sys/posix/SystemInfo.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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<Address> &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); } |