- fixed GH# 71: WebSocket and broken Timeouts (POCO_BROKEN_TIMEOUTS)

- fixed an ambiguity error with VC++ 2010 in Data/MySQL testsuite
- Poco::Net::NetworkInterface now provides the interface index even for IPv4
- added DNS::reload() as a wrapper for res_init().
- On Linux, Poco::Environment::nodeId() first always tries to obtain the
  MAC address of eth0, before looking for other interfaces.
- Poco::Net::HTTPSession now always resets the buffer in connect() to clear
  any leftover data from a (failed) previous session
- fixed copysign namespace issue in FPEnvironment_DUMMY.h
- fixed a warning in Poco/Crypto/OpenSSLInitializer.h
- added a build configuration for BeagleBoard/Angstrom
This commit is contained in:
Guenter Obiltschnig
2013-02-14 16:52:39 +01:00
parent 9d3512459e
commit 4ced78acb9
13 changed files with 206 additions and 49 deletions

View File

@@ -1,7 +1,7 @@
//
// OpenSSLInitializer.h
//
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/OpenSSLInitializer.h#1 $
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/OpenSSLInitializer.h#2 $
//
// Library: Crypto
// Package: CryptoCore
@@ -119,12 +119,16 @@ inline bool OpenSSLInitializer::isFIPSEnabled()
}
#ifdef OPENSSL_FIPS
inline void OpenSSLInitializer::enableFIPSMode(bool enabled)
{
#ifdef OPENSSL_FIPS
FIPS_mode_set(enabled);
#endif
}
#else
inline void OpenSSLInitializer::enableFIPSMode(bool /*enabled*/)
{
}
#endif
} } // namespace Poco::Crypto

View File

@@ -1,7 +1,7 @@
//
// SQLExecutor.cpp
//
// $Id: //poco/1.4/Data/MySQL/testsuite/src/SQLExecutor.cpp#1 $
// $Id: //poco/1.4/Data/MySQL/testsuite/src/SQLExecutor.cpp#2 $
//
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -1405,7 +1405,7 @@ void SQLExecutor::internalExtraction()
int i = rset.value<int>(0,0);
assert (1 == i);
std::string s = rset.value(0,0);
std::string s = rset.value(0,0).convert<std::string>();
assert ("1" == s);
int a = rset.value<int>(0,2);

View File

@@ -1,7 +1,7 @@
//
// FPEnvironment_DUMMY.h
//
// $Id: //poco/1.4/Foundation/include/Poco/FPEnvironment_DUMMY.h#3 $
// $Id: //poco/1.4/Foundation/include/Poco/FPEnvironment_DUMMY.h#4 $
//
// Library: Foundation
// Package: Core
@@ -131,21 +131,13 @@ inline bool FPEnvironmentImpl::isNaNImpl(long double value)
inline float FPEnvironmentImpl::copySignImpl(float target, float source)
{
#if defined(__APPLE__) || defined(POCO_ANDROID)
return copysignf(target, source);
#else
return std::copysignf(target, source);
#endif
}
inline double FPEnvironmentImpl::copySignImpl(double target, double source)
{
#if defined(__APPLE__) || defined(POCO_ANDROID)
return copysign(target, source);
#else
return std::copysign(target, source);
#endif
}

View File

@@ -1,7 +1,7 @@
//
// Thread.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Thread.h#5 $
// $Id: //poco/1.4/Foundation/include/Poco/Thread.h#6 $
//
// Library: Foundation
// Package: Threading
@@ -160,6 +160,10 @@ public:
void start(Runnable& target);
/// Starts the thread with the given target.
///
/// Note that the given Runnable object must be
/// valid during the entire lifetime of the thread, as
/// only a reference to it is stored internally.
void start(Callable target, void* pData = 0);
/// Starts the thread with the given target and parameter.

View File

@@ -1,7 +1,7 @@
// Environment_UNIX.cpp
//
// $Id: //poco/1.4/Foundation/src/Environment_UNIX.cpp#3 $
// $Id: //poco/1.4/Foundation/src/Environment_UNIX.cpp#4 $
//
// Library: Foundation
// Package: Core
@@ -42,7 +42,6 @@
#include <stdlib.h>
#include <sys/utsname.h>
#include <sys/param.h>
#include <cstring>
#if defined(POCO_OS_FAMILY_BSD)
#include <sys/sysctl.h>
#elif POCO_OS == POCO_OS_HPUX
@@ -215,6 +214,10 @@ void EnvironmentImpl::nodeIdImpl(NodeId& id)
#endif
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cstdio>
namespace Poco {
@@ -223,6 +226,26 @@ namespace Poco {
void EnvironmentImpl::nodeIdImpl(NodeId& id)
{
std::memset(&id, 0, sizeof(id));
// ideally, the following code should be rewritten
// to use netlink
// first try to obtain the MAC address of eth0 using /sys/class/net
int fd = open("/sys/class/net/eth0/address", O_RDONLY);
if (fd >= 0)
{
char buffer[18];
int n = read(fd, buffer, 17);
close(fd);
if (n == 17)
{
buffer[n] = 0;
if (std::sscanf(buffer, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &id[0], &id[1], &id[2], &id[3], &id[4], &id[5]) == 6)
return;
}
}
// if that did not work, search active interfaces
int sock = socket(PF_INET, SOCK_DGRAM, 0);
if (sock == -1) return;

View File

@@ -1,7 +1,7 @@
//
// DNS.h
//
// $Id: //poco/1.4/Net/include/Poco/Net/DNS.h#2 $
// $Id: //poco/1.4/Net/include/Poco/Net/DNS.h#3 $
//
// Library: Net
// Package: NetCore
@@ -44,7 +44,6 @@
#include "Poco/Net/SocketDefs.h"
#include "Poco/Net/IPAddress.h"
#include "Poco/Net/HostEntry.h"
#include "Poco/Mutex.h"
namespace Poco {
@@ -115,6 +114,13 @@ public:
///
/// Throws an IOException in case of any other error.
static void reload();
/// Reloads the resolver configuration.
///
/// This method will call res_init() if the Net library
/// has been compiled with -DPOCO_HAVE_LIBRESOLV. Otherwise
/// it will do nothing.
//@ deprecated
static void flushCache();
/// Flushes the internal DNS cache.

View File

@@ -1,7 +1,7 @@
//
// WebSocketImpl.h
//
// $Id: //poco/1.4/Net/include/Poco/Net/WebSocketImpl.h#5 $
// $Id: //poco/1.4/Net/include/Poco/Net/WebSocketImpl.h#6 $
//
// Library: Net
// Package: WebSocket
@@ -78,6 +78,10 @@ public:
virtual int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0);
virtual void sendUrgent(unsigned char data);
virtual bool secure() const;
virtual void setSendTimeout(const Poco::Timespan& timeout);
virtual Poco::Timespan getSendTimeout();
virtual void setReceiveTimeout(const Poco::Timespan& timeout);
virtual Poco::Timespan getReceiveTimeout();
// Internal
int frameFlags() const;

View File

@@ -1,7 +1,7 @@
//
// DNS.cpp
//
// $Id: //poco/1.4/Net/src/DNS.cpp#11 $
// $Id: //poco/1.4/Net/src/DNS.cpp#12 $
//
// Library: Net
// Package: NetCore
@@ -39,11 +39,15 @@
#include "Poco/Net/SocketAddress.h"
#include "Poco/Environment.h"
#include "Poco/NumberFormatter.h"
#include "Poco/AtomicCounter.h"
#include "Poco/RWLock.h"
#include <cstring>
using Poco::FastMutex;
#if defined(POCO_HAVE_LIBRESOLV)
#include <resolv.h>
#endif
using Poco::Environment;
using Poco::NumberFormatter;
using Poco::IOException;
@@ -71,9 +75,18 @@ namespace Poco {
namespace Net {
#if defined(POCO_HAVE_LIBRESOLV)
static Poco::RWLock resolverLock;
#endif
HostEntry DNS::hostByName(const std::string& hostname)
{
NetworkInitializer networkInitializer;
#if defined(POCO_HAVE_LIBRESOLV)
Poco::ScopedReadRWLock readLock(resolverLock);
#endif
#if defined(POCO_HAVE_IPv6) || defined(POCO_HAVE_ADDRINFO)
struct addrinfo* pAI;
@@ -104,7 +117,7 @@ HostEntry DNS::hostByName(const std::string& hostname)
return HostEntry(he);
}
#endif
error(lastError(), hostname); // will throw an appropriate exception
error(lastError(), hostname); // will throw an appropriate exception
throw NetException(); // to silence compiler
}
@@ -113,6 +126,10 @@ HostEntry DNS::hostByAddress(const IPAddress& address)
{
NetworkInitializer networkInitializer;
#if defined(POCO_HAVE_LIBRESOLV)
Poco::ScopedReadRWLock readLock(resolverLock);
#endif
#if defined(POCO_HAVE_IPv6) || defined(POCO_HAVE_ADDRINFO)
SocketAddress sa(address, 0);
static char fqname[1024];
@@ -188,6 +205,15 @@ HostEntry DNS::thisHost()
}
void DNS::reload()
{
#if defined(POCO_HAVE_LIBRESOLV)
Poco::ScopedWriteRWLock writeLock(resolverLock);
res_init();
#endif
}
void DNS::flushCache()
{
}
@@ -242,7 +268,7 @@ void DNS::error(int code, const std::string& arg)
void DNS::aierror(int code, const std::string& arg)
{
#if defined(POCO_HAVE_IPv6)
#if defined(POCO_HAVE_IPv6) || defined(POCO_HAVE_ADDRINFO)
switch (code)
{
case EAI_AGAIN:
@@ -267,7 +293,7 @@ void DNS::aierror(int code, const std::string& arg)
default:
throw DNSException("EAI", NumberFormatter::format(code));
}
#endif // POCO_HAVE_IPv6
#endif // POCO_HAVE_IPv6 || defined(POCO_HAVE_ADDRINFO)
}

View File

@@ -1,7 +1,7 @@
//
// HTTPSession.cpp
//
// $Id: //poco/1.4/Net/src/HTTPSession.cpp#2 $
// $Id: //poco/1.4/Net/src/HTTPSession.cpp#3 $
//
// Library: Net
// Package: HTTP
@@ -197,6 +197,9 @@ void HTTPSession::connect(const SocketAddress& address)
_socket.connect(address, _timeout);
_socket.setReceiveTimeout(_timeout);
_socket.setNoDelay(true);
// There may be leftover data from a previous (failed) request in the buffer,
// so we clear it.
_pCurrent = _pEnd = _pBuffer;
}

View File

@@ -1,7 +1,7 @@
//
// NetworkInterface.cpp
//
// $Id: //poco/1.4/Net/src/NetworkInterface.cpp#11 $
// $Id: //poco/1.4/Net/src/NetworkInterface.cpp#14 $
//
// Library: Net
// Package: Sockets
@@ -98,7 +98,7 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& name, const std::s
_index(index)
{
#if !defined(_WIN32) && !defined(POCO_VXWORKS)
if (index == -1) // IPv4
if (address.family() == IPAddress::IPv4)
{
struct ifreq ifr;
std::strncpy(ifr.ifr_name, name.c_str(), IFNAMSIZ);
@@ -280,13 +280,13 @@ const IPAddress& NetworkInterface::broadcastAddress() const
bool NetworkInterface::supportsIPv4() const
{
return _pImpl->index() == -1;
return _pImpl->address().family() == Poco::Net::IPAddress::IPv4;
}
bool NetworkInterface::supportsIPv6() const
{
return _pImpl->index() != -1;
return _pImpl->address().family() == Poco::Net::IPAddress::IPv6;
}
@@ -433,19 +433,14 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
pAdapterAddresses = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(new char[addrLen]);
// Make an initial call to GetAdaptersAddresses to get
// the necessary size into addrLen
rc = GetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &addrLen);
if (rc == ERROR_BUFFER_OVERFLOW)
while ((rc = GetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &addrLen)) == ERROR_BUFFER_OVERFLOW)
{
delete [] reinterpret_cast<char*>(pAdapterAddresses);
pAdapterAddresses = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(new char[addrLen]);
}
else if (rc != ERROR_SUCCESS)
{
throw NetException("cannot get network adapter list");
}
try
{
if (GetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &addrLen) == NO_ERROR)
if (rc == NO_ERROR)
{
pAddress = pAdapterAddresses;
while (pAddress)
@@ -477,7 +472,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
broadcastAddress = address;
broadcastAddress.mask(subnetMask, IPAddress::broadcast());
}
result.push_back(NetworkInterface(name, displayName, address, subnetMask, broadcastAddress));
result.push_back(NetworkInterface(name, displayName, address, subnetMask, broadcastAddress, pAddress->IfIndex));
break;
case AF_INET6:
address = IPAddress(&reinterpret_cast<struct sockaddr_in6*>(pUniAddr->Address.lpSockaddr)->sin6_addr, sizeof(in6_addr), reinterpret_cast<struct sockaddr_in6*>(pUniAddr->Address.lpSockaddr)->sin6_scope_id);
@@ -502,7 +497,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
#endif // POCO_HAVE_IPv6
// Add IPv4 loopback interface (not returned by GetAdaptersInfo)
result.push_back(NetworkInterface("Loopback", "Loopback Interface", IPAddress("127.0.0.1"), IPAddress("255.0.0.0"), IPAddress(), -1));
result.push_back(NetworkInterface("Loopback", "Loopback Pseudo-Interface", IPAddress("127.0.0.1"), IPAddress("255.0.0.0"), IPAddress(), 1));
// On Windows 2000 we use GetAdaptersInfo.
PIP_ADAPTER_INFO pAdapterInfo;
PIP_ADAPTER_INFO pInfo = 0;
@@ -538,7 +533,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
broadcastAddress.mask(subnetMask, IPAddress::broadcast());
std::string name(pInfo->AdapterName);
std::string displayName(pInfo->Description);
result.push_back(NetworkInterface(name, displayName, address, subnetMask, broadcastAddress));
result.push_back(NetworkInterface(name, displayName, address, subnetMask, broadcastAddress, pInfo->Index));
}
pIpAddressList = pIpAddressList->Next;
}
@@ -601,7 +596,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
{
bcst = IPAddress(std::string(ifAddr));
}
result.push_back(NetworkInterface(name, name, addr, mask, bcst));
result.push_back(NetworkInterface(name, name, addr, mask, bcst, ifIndex));
ifIndex++;
}
else break;
@@ -649,7 +644,8 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
IPAddress broadcastAddr;
if (ifap->ifa_flags & IFF_BROADCAST)
broadcastAddr = IPAddress(&reinterpret_cast<struct sockaddr_in*>(ifap->ifa_dstaddr)->sin_addr, sizeof(struct in_addr));
result.push_back(NetworkInterface(name, name, addr, subnetMask, broadcastAddr));
Poco::UInt32 ifIndex = if_nametoindex(ifap->ifa_name);
result.push_back(NetworkInterface(name, name, addr, subnetMask, broadcastAddr, ifIndex));
}
#if defined(POCO_HAVE_IPv6)
else if (ifap->ifa_addr->sa_family == AF_INET6)
@@ -710,7 +706,8 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
haveAddr = true;
break;
case AF_INET:
addr = IPAddress(&reinterpret_cast<const struct sockaddr_in*>(currIface->ifa_addr)->sin_addr, sizeof(struct in_addr));
ifIndex = if_nametoindex(currIface->ifa_name);
addr = IPAddress(&reinterpret_cast<const struct sockaddr_in*>(currIface->ifa_addr)->sin_addr, sizeof(struct in_addr), ifIndex);
haveAddr = true;
break;
default:
@@ -790,7 +787,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
}
if (haveAddr)
{
int index = -1;
int index = if_nametoindex(ifr->ifr_name);
std::string name(ifr->ifr_name);
result.push_back(NetworkInterface(name, name, addr, index));
}
@@ -878,8 +875,9 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
break;
#endif
case AF_INET:
ifIndex = if_nametoindex(ifr->ifr_name);
if (len < sizeof(struct sockaddr_in)) len = sizeof(struct sockaddr_in);
addr = IPAddress(&reinterpret_cast<const struct sockaddr_in*>(&ifr->ifr_addr)->sin_addr, sizeof(struct in_addr));
addr = IPAddress(&reinterpret_cast<const struct sockaddr_in*>(&ifr->ifr_addr)->sin_addr, sizeof(struct in_addr), ifIndex);
haveAddr = true;
break;
default:

View File

@@ -1,7 +1,7 @@
//
// WebSocketImpl.cpp
//
// $Id: //poco/1.4/Net/src/WebSocketImpl.cpp#6 $
// $Id: //poco/1.4/Net/src/WebSocketImpl.cpp#7 $
//
// Library: Net
// Package: WebSocket
@@ -297,5 +297,29 @@ bool WebSocketImpl::secure() const
return _pStreamSocketImpl->secure();
}
void WebSocketImpl::setSendTimeout(const Poco::Timespan& timeout)
{
_pStreamSocketImpl->setSendTimeout(timeout);
}
Poco::Timespan WebSocketImpl::getSendTimeout()
{
return _pStreamSocketImpl->getSendTimeout();
}
void WebSocketImpl::setReceiveTimeout(const Poco::Timespan& timeout)
{
_pStreamSocketImpl->setReceiveTimeout(timeout);
}
Poco::Timespan WebSocketImpl::getReceiveTimeout()
{
return _pStreamSocketImpl->getReceiveTimeout();
}
} } // namespace Poco::Net

73
build/config/BeagleBoard Normal file
View File

@@ -0,0 +1,73 @@
#
# $Id: //poco/1.4/build/config/BeagleBoard#1 $
#
# BeagleBoard
#
# Make settings for Open Embedded/Angstrom BeagleBoard
#
#
# General Settings
#
LINKMODE ?= SHARED
POCO_TARGET_OSNAME = Linux
POCO_TARGET_OSARCH = armv7l
TOOL = arm-angstrom-linux-gnueabi
#
# Define Tools
#
CC = $(TOOL)-gcc
CXX = $(TOOL)-g++
LINK = $(CXX)
STRIP = $(TOOL)-strip
LIB = $(TOOL)-ar -cr
RANLIB = $(TOOL)-ranlib
SHLIB = $(CXX) -shared -Wl,-soname,$(notdir $@) -o $@
SHLIBLN = $(POCO_BASE)/build/script/shlibln
DEP = $(POCO_BASE)/build/script/makedepend.gcc
SHELL = sh
RM = rm -rf
CP = cp
MKDIR = mkdir -p
#
# Extension for Shared Libraries
#
SHAREDLIBEXT = .so.$(target_version)
SHAREDLIBLINKEXT = .so
#
# Compiler and Linker Flags
#
CFLAGS = -mfpu=neon -mfloat-abi=softfp -march=armv7-a
CFLAGS32 =
CFLAGS64 =
CXXFLAGS = -mfpu=neon -mfloat-abi=softfp -march=armv7-a
CXXFLAGS32 =
CXXFLAGS64 =
LINKFLAGS =
LINKFLAGS32 =
LINKFLAGS64 =
STATICOPT_CC =
STATICOPT_CXX =
STATICOPT_LINK = -static
SHAREDOPT_CC = -fPIC
SHAREDOPT_CXX = -fPIC
SHAREDOPT_LINK = -Wl,-rpath,$(LIBPATH)
DEBUGOPT_CC = -g -D_DEBUG
DEBUGOPT_CXX = -g -D_DEBUG
DEBUGOPT_LINK = -g
RELEASEOPT_CC = -O3 -DNDEBUG
RELEASEOPT_CXX = -O2 -DNDEBUG
RELEASEOPT_LINK = -O2
#
# System Specific Flags
#
SYSFLAGS = -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_REENTRANT -D_THREAD_SAFE -DPOCO_NO_FPENVIRONMENT
#
# System Specific Libraries
#
SYSLIBS = -lpthread -ldl -lrt

View File

@@ -1,5 +1,5 @@
#
# $Id: //poco/1.4/build/config/DigiEL#2 $
# $Id: //poco/1.4/build/config/DigiEL#3 $
#
# DigiEL
#
@@ -65,7 +65,7 @@ RELEASEOPT_LINK = -O2
#
# System Specific Flags
#
SYSFLAGS = -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_REENTRANT -D_THREAD_SAFE -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY
SYSFLAGS = -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_REENTRANT -D_THREAD_SAFE -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY -DPOCO_HAVE_ADDRINFO -DPOCO_HAVE_LIBRESOLV
#
# System Specific Libraries