summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2009-05-28 20:11:13 +0000
committerAndrew Stitcher <astitcher@apache.org>2009-05-28 20:11:13 +0000
commit3cd98a374cde935d7056a35811e348f81e3214fe (patch)
tree47193a080b04086fa0b45f5e0ebff62c46a3a9f0 /cpp/src
parentd0ad549db4560c79d5631bb79d3c53dc75c89741 (diff)
downloadqpid-python-3cd98a374cde935d7056a35811e348f81e3214fe.tar.gz
Fixes to get qpid to build with gcc4.4 with optimisation
Fix for non thread safe use of inet_ntoa(). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@779757 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/cluster.mk1
-rwxr-xr-xcpp/src/qpid/sys/posix/SystemInfo.cpp14
2 files changed, 11 insertions, 4 deletions
diff --git a/cpp/src/cluster.mk b/cpp/src/cluster.mk
index 965c335306..808c96c7a7 100644
--- a/cpp/src/cluster.mk
+++ b/cpp/src/cluster.mk
@@ -82,6 +82,7 @@ cluster_la_SOURCES = \
qpid/sys/LatencyTracker.h
cluster_la_LIBADD= -lcpg $(libcman) libqpidbroker.la libqpidclient.la
+cluster_la_CXXFLAGS = $(AM_CXXFLAGS) -fno-strict-aliasing
cluster_la_LDFLAGS = $(PLUGINLDFLAGS)
endif # HAVE_LIBCPG
diff --git a/cpp/src/qpid/sys/posix/SystemInfo.cpp b/cpp/src/qpid/sys/posix/SystemInfo.cpp
index db3b48e6fe..f7d16c12c8 100755
--- a/cpp/src/qpid/sys/posix/SystemInfo.cpp
+++ b/cpp/src/qpid/sys/posix/SystemInfo.cpp
@@ -20,6 +20,8 @@
#include "qpid/sys/SystemInfo.h"
+#include "check.h"
+
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <net/if.h>
@@ -30,6 +32,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
+#include <netdb.h>
#ifndef HOST_NAME_MAX
# define HOST_NAME_MAX 256
@@ -60,17 +63,20 @@ static const string LOCALHOST("127.0.0.1");
void SystemInfo::getLocalIpAddresses (uint16_t port,
std::vector<Address> &addrList) {
- int s = socket (PF_INET, SOCK_STREAM, 0);
+ int s = ::socket(PF_INET, SOCK_STREAM, 0);
for (int i=1;;i++) {
- struct ifreq ifr;
+ ::ifreq ifr;
ifr.ifr_ifindex = i;
if (::ioctl (s, SIOCGIFNAME, &ifr) < 0)
break;
/* now ifr.ifr_name is set */
if (::ioctl (s, SIOCGIFADDR, &ifr) < 0)
continue;
- struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr;
- string addr(inet_ntoa(sin->sin_addr));
+ ::sockaddr *saddr = (::sockaddr *) &ifr.ifr_addr;
+ char dispName[NI_MAXHOST];
+ if (int rc=::getnameinfo(saddr, sizeof(ifr.ifr_addr), dispName, sizeof(dispName), 0, 0, NI_NUMERICHOST) != 0)
+ throw QPID_POSIX_ERROR(rc);
+ string addr(dispName);
if (addr != LOCALHOST)
addrList.push_back(TcpAddress(addr, port));
}