summaryrefslogtreecommitdiff
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
commitc287f7df53ace7c36b5b98bbda63c8a77ba0c1fa (patch)
tree0ce924a32aa79394f225d71195647c524eda5a2f
parent814df615ce82d893a3393abf2efff6f2317f13fe (diff)
downloadqpid-python-c287f7df53ace7c36b5b98bbda63c8a77ba0c1fa.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@779757 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/cluster.mk1
-rwxr-xr-xqpid/cpp/src/qpid/sys/posix/SystemInfo.cpp14
2 files changed, 11 insertions, 4 deletions
diff --git a/qpid/cpp/src/cluster.mk b/qpid/cpp/src/cluster.mk
index 965c335306..808c96c7a7 100644
--- a/qpid/cpp/src/cluster.mk
+++ b/qpid/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/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp b/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
index db3b48e6fe..f7d16c12c8 100755
--- a/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
+++ b/qpid/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));
}