Merge remote-tracking branch 'origin/poco-1.8.0' into poco-1.8.0

This commit is contained in:
zosrothko 2017-11-07 15:05:44 +01:00
commit bdd371e996
9 changed files with 57 additions and 194 deletions

View File

@ -365,11 +365,7 @@ public:
private:
typedef Poco::Net::Impl::IPAddressImpl Impl;
#ifdef POCO_HAVE_ALIGNMENT
typedef Impl* Ptr;
#else
typedef Poco::AutoPtr<Impl> Ptr;
#endif
Ptr pImpl() const;
void newIPv4();
@ -381,86 +377,35 @@ private:
void newIPv6(const void* hostAddr, Poco::UInt32 scope);
void newIPv6(unsigned prefix);
#endif
void destruct();
#ifdef POCO_HAVE_ALIGNMENT
char* storage();
#ifdef POCO_ENABLE_CPP11
static const unsigned sz = sizeof(Poco::Net::Impl::IPv6AddressImpl);
typedef std::aligned_storage<sz>::type AlignerType;
union
{
char buffer[sz];
private:
AlignerType aligner;
}
#else // !POCO_ENABLE_CPP11
#if defined(POCO_HAVE_IPv6)
AlignedCharArrayUnion <Poco::Net::Impl::IPv6AddressImpl>
#else
AlignedCharArrayUnion <Poco::Net::Impl::IPv4AddressImpl>
#endif
#endif // POCO_ENABLE_CPP11
_memory;
#else // !POCO_HAVE_ALIGNMENT
Ptr _pImpl;
#endif // POCO_HAVE_ALIGNMENT
};
//
// inlines
//
inline void IPAddress::destruct()
{
#ifdef POCO_HAVE_ALIGNMENT
pImpl()->~IPAddressImpl();
#endif
}
inline IPAddress::Ptr IPAddress::pImpl() const
{
#ifdef POCO_HAVE_ALIGNMENT
return reinterpret_cast<Ptr>(const_cast<char *>(_memory.buffer));
#else
if (_pImpl) return _pImpl;
throw NullPointerException("IPaddress implementation pointer is NULL.");
#endif
}
inline void IPAddress::newIPv4()
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4AddressImpl;
#else
_pImpl = new Poco::Net::Impl::IPv4AddressImpl;
#endif
}
inline void IPAddress::newIPv4(const void* hostAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4AddressImpl(hostAddr);
#else
_pImpl = new Poco::Net::Impl::IPv4AddressImpl(hostAddr);
#endif
}
inline void IPAddress::newIPv4(unsigned prefix)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4AddressImpl(prefix);
#else
_pImpl = new Poco::Net::Impl::IPv4AddressImpl(prefix);
#endif
}
@ -469,55 +414,31 @@ inline void IPAddress::newIPv4(unsigned prefix)
inline void IPAddress::newIPv6()
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6AddressImpl;
#else
_pImpl = new Poco::Net::Impl::IPv6AddressImpl;
#endif
}
inline void IPAddress::newIPv6(const void* hostAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6AddressImpl(hostAddr);
#else
_pImpl = new Poco::Net::Impl::IPv6AddressImpl(hostAddr);
#endif
}
inline void IPAddress::newIPv6(const void* hostAddr, Poco::UInt32 scope)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6AddressImpl(hostAddr, scope);
#else
_pImpl = new Poco::Net::Impl::IPv6AddressImpl(hostAddr, scope);
#endif
}
inline void IPAddress::newIPv6(unsigned prefix)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6AddressImpl(prefix);
#else
_pImpl = new Poco::Net::Impl::IPv6AddressImpl(prefix);
#endif
}
#endif // POCO_HAVE_IPv6
#ifdef POCO_HAVE_ALIGNMENT
inline char* IPAddress::storage()
{
return _memory.buffer;
}
#endif
} } // namespace Poco::Net

View File

@ -20,9 +20,7 @@
#include "Poco/Net/Net.h"
#include "Poco/Net/SocketDefs.h"
#ifndef POCO_HAVE_ALIGNMENT
#include "Poco/RefCountedObject.h"
#endif
#include <vector>
@ -31,10 +29,7 @@ namespace Net {
namespace Impl {
class IPAddressImpl
#ifndef POCO_HAVE_ALIGNMENT
: public Poco::RefCountedObject
#endif
class IPAddressImpl : public Poco::RefCountedObject
{
public:
typedef AddressFamily::Family Family;

View File

@ -195,11 +195,7 @@ protected:
private:
typedef Poco::Net::Impl::SocketAddressImpl Impl;
#ifdef POCO_HAVE_ALIGNMENT
typedef Impl* Ptr;
#else
typedef Poco::AutoPtr<Impl> Ptr;
#endif
Ptr pImpl() const;
@ -217,106 +213,48 @@ private:
void newLocal(const std::string& path);
#endif
void destruct();
#ifdef POCO_HAVE_ALIGNMENT
char* storage();
#ifdef POCO_ENABLE_CPP11
static const unsigned sz = sizeof(Poco::Net::Impl::IPv6SocketAddressImpl);
typedef std::aligned_storage<sz>::type AlignerType;
union
{
char buffer[sz];
private:
AlignerType aligner;
}
#else // !POCO_ENABLE_CPP11
#if defined(POCO_HAVE_IPv6)
AlignedCharArrayUnion <Poco::Net::Impl::IPv6SocketAddressImpl>
#else
AlignedCharArrayUnion <Poco::Net::Impl::IPv4SocketAddressImpl>
#endif
#endif // POCO_ENABLE_CPP11
_memory;
#else // !POCO_HAVE_ALIGNMENT
Ptr _pImpl;
#endif // POCO_HAVE_ALIGNMENT
};
//
// inlines
//
inline void SocketAddress::destruct()
{
#ifdef POCO_HAVE_ALIGNMENT
pImpl()->~SocketAddressImpl();
#endif
}
inline SocketAddress::Ptr SocketAddress::pImpl() const
{
#ifdef POCO_HAVE_ALIGNMENT
return reinterpret_cast<Ptr>(const_cast<char *>(_memory.buffer));
#else
if (_pImpl) return _pImpl;
throw Poco::NullPointerException("Pointer to SocketAddress implementation is NULL.");
#endif
}
inline void SocketAddress::newIPv4()
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4SocketAddressImpl;
#else
_pImpl = new Poco::Net::Impl::IPv4SocketAddressImpl;
#endif
}
inline void SocketAddress::newIPv4(const sockaddr_in* sockAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4SocketAddressImpl(sockAddr);
#else
_pImpl = new Poco::Net::Impl::IPv4SocketAddressImpl(sockAddr);
#endif
}
inline void SocketAddress::newIPv4(const IPAddress& hostAddress, Poco::UInt16 portNumber)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv4SocketAddressImpl(hostAddress.addr(), htons(portNumber));
#else
_pImpl = new Poco::Net::Impl::IPv4SocketAddressImpl(hostAddress.addr(), htons(portNumber));
#endif
}
#if defined(POCO_HAVE_IPv6)
inline void SocketAddress::newIPv6(const sockaddr_in6* sockAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6SocketAddressImpl(sockAddr);
#else
_pImpl = new Poco::Net::Impl::IPv6SocketAddressImpl(sockAddr);
#endif
}
inline void SocketAddress::newIPv6(const IPAddress& hostAddress, Poco::UInt16 portNumber)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::IPv6SocketAddressImpl(hostAddress.addr(), htons(portNumber), hostAddress.scope());
#else
_pImpl = new Poco::Net::Impl::IPv6SocketAddressImpl(hostAddress.addr(), htons(portNumber), hostAddress.scope());
#endif
}
#endif // POCO_HAVE_IPv6
@ -324,34 +262,18 @@ inline void SocketAddress::newIPv6(const IPAddress& hostAddress, Poco::UInt16 po
#if defined(POCO_OS_FAMILY_UNIX)
inline void SocketAddress::newLocal(const sockaddr_un* sockAddr)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::LocalSocketAddressImpl(sockAddr);
#else
_pImpl = new Poco::Net::Impl::LocalSocketAddressImpl(sockAddr);
#endif
}
inline void SocketAddress::newLocal(const std::string& path)
{
#ifdef POCO_HAVE_ALIGNMENT
new (storage()) Poco::Net::Impl::LocalSocketAddressImpl(path.c_str());
#else
_pImpl = new Poco::Net::Impl::LocalSocketAddressImpl(path.c_str());
#endif
}
#endif // POCO_OS_FAMILY_UNIX
#ifdef POCO_HAVE_ALIGNMENT
inline char* SocketAddress::storage()
{
return _memory.buffer;
}
#endif
inline bool SocketAddress::operator == (const SocketAddress& socketAddress) const
inline bool SocketAddress::operator == (const SocketAddress& socketAddress) const
{
#if defined(POCO_OS_FAMILY_UNIX)
if (family() == UNIX_LOCAL)

View File

@ -21,9 +21,7 @@
#include "Poco/Net/Net.h"
#include "Poco/Net/SocketDefs.h"
#include "Poco/Net/IPAddress.h"
#ifndef POCO_HAVE_ALIGNMENT
#include "Poco/RefCountedObject.h"
#endif
namespace Poco {
@ -31,10 +29,7 @@ namespace Net {
namespace Impl {
class Net_API SocketAddressImpl
#ifndef POCO_HAVE_ALIGNMENT
: public Poco::RefCountedObject
#endif
class Net_API SocketAddressImpl : public Poco::RefCountedObject
{
public:
typedef AddressFamily::Family Family;

View File

@ -138,9 +138,7 @@ IPAddress::IPAddress(const std::string& addr, Family family)
IPAddress::IPAddress(const void* addr, poco_socklen_t length)
#ifndef POCO_HAVE_ALIGNMENT
: _pImpl(0)
#endif
{
if (length == sizeof(struct in_addr))
newIPv4(addr);
@ -188,9 +186,7 @@ IPAddress::IPAddress(unsigned prefix, Family family)
#if defined(_WIN32)
IPAddress::IPAddress(const SOCKET_ADDRESS& socket_address)
#ifndef POCO_HAVE_ALIGNMENT
: _pImpl(0)
#endif
{
ADDRESS_FAMILY family = socket_address.lpSockaddr->sa_family;
if (family == AF_INET)
@ -221,7 +217,6 @@ IPAddress::IPAddress(const struct sockaddr& sockaddr)
IPAddress::~IPAddress()
{
destruct();
}
@ -229,7 +224,6 @@ IPAddress& IPAddress::operator = (const IPAddress& addr)
{
if (&addr != this)
{
destruct();
if (addr.family() == IPAddress::IPv4)
newIPv4(addr.addr());
#if defined(POCO_HAVE_IPv6)

View File

@ -168,7 +168,6 @@ SocketAddress::SocketAddress(const struct sockaddr* sockAddr, poco_socklen_t len
SocketAddress::~SocketAddress()
{
destruct();
}
@ -189,7 +188,6 @@ SocketAddress& SocketAddress::operator = (const SocketAddress& socketAddress)
{
if (&socketAddress != this)
{
destruct();
if (socketAddress.family() == IPv4)
newIPv4(reinterpret_cast<const sockaddr_in*>(socketAddress.addr()));
#if defined(POCO_HAVE_IPv6)

View File

@ -55,13 +55,13 @@ WebSocketImpl::~WebSocketImpl()
}
}
int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
{
Poco::Buffer<char> frame(length + MAX_HEADER_LENGTH);
Poco::MemoryOutputStream ostr(frame.begin(), frame.size());
Poco::BinaryWriter writer(ostr, Poco::BinaryWriter::NETWORK_BYTE_ORDER);
if (flags == 0) flags = WebSocket::FRAME_BINARY;
flags &= 0xff;
writer << static_cast<Poco::UInt8>(flags);
@ -105,7 +105,7 @@ int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
return length;
}
int WebSocketImpl::receiveHeader(char mask[4], bool& useMask)
{
char header[MAX_HEADER_LENGTH];
@ -318,7 +318,7 @@ void WebSocketImpl::shutdownSend()
_pStreamSocketImpl->shutdownSend();
}
void WebSocketImpl::shutdown()
{
_pStreamSocketImpl->shutdown();
@ -375,8 +375,12 @@ Poco::Timespan WebSocketImpl::getReceiveTimeout()
int WebSocketImpl::available()
{
return _pStreamSocketImpl->available();
int n = _buffer.size() - _bufferOffset;
if (n > 0)
return n + _pStreamSocketImpl->available();
else
return _pStreamSocketImpl->available();
}
} } // namespace Poco::Net

View File

@ -14,6 +14,18 @@ find_path(MYSQL_INCLUDE_DIR mysql.h
${BINDIR32}/MySQL/include
$ENV{SystemDrive}/MySQL/*/include)
if (NOT MYSQL_INCLUDE_DIR)
find_path(MARIADB_INCLUDE_DIR mysql.h
/usr/include/mariadb
/usr/local/include/mariadb
/opt/mariadb/mariadb/include
/opt/mariadb/mariadb/include/mariadb
/usr/local/mariadb/include
/usr/local/mariadb/include/mariadb
$ENV{MARIADB_INCLUDE_DIR}
$ENV{MARIADB_DIR}/include)
endif (NOT MYSQL_INCLUDE_DIR)
if (WIN32)
if (CMAKE_BUILD_TYPE STREQUAL Debug)
set(libsuffixDist debug)
@ -44,17 +56,39 @@ else (WIN32)
$ENV{MYSQL_DIR}/libmysql_r/.libs
$ENV{MYSQL_DIR}/lib
$ENV{MYSQL_DIR}/lib/mysql)
if (NOT MYSQL_LIB)
find_library(MARIADB_LIB NAMES mariadbclient
PATHS
/usr/lib/mariadb
/usr/local/lib/mariadb
/usr/local/mariadb/lib
/usr/local/mariadb/lib/mariadb
/opt/mariadb/mariadb/lib
/opt/mariadb/mariadb/lib/mariadb
$ENV{MARIADB_DIR}/libmariadb/.libs
$ENV{MARIADB_DIR}/lib
$ENV{MARIADB_DIR}/lib/mariadb)
endif (NOT MYSQL_LIB)
endif (WIN32)
if(MYSQL_LIB)
if (MYSQL_INCLUDE_DIR AND MYSQL_LIB)
get_filename_component(MYSQL_LIB_DIR ${MYSQL_LIB} PATH)
endif(MYSQL_LIB)
if (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)
set(MYSQL_FOUND TRUE)
message(STATUS "MySQL Include directory: ${MYSQL_INCLUDE_DIR} library directory: ${MYSQL_LIB_DIR}")
message(STATUS "Found MySQL Include directory: ${MYSQL_INCLUDE_DIR} library directory: ${MYSQL_LIB_DIR}")
include_directories(${MYSQL_INCLUDE_DIR})
link_directories(${MYSQL_LIB_DIR})
else (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)
message(STATUS "Couldn't find MySQL")
endif (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)
elseif((MARIADB_INCLUDE_DIR OR MYSQL_INCLUDE_DIR) AND MARIADB_LIB)
get_filename_component(MYSQL_LIB_DIR ${MARIADB_LIB} PATH)
set(MYSQL_FOUND TRUE)
set(MYSQL_LIB ${MARIADB_LIB})
if(MARIADB_INCLUDE_DIR)
set(MYSQL_INCLUDE_DIR ${MARIADB_INCLUDE_DIR})
endif(MARIADB_INCLUDE_DIR)
message(STATUS "Found MariaDB Include directory: ${MYSQL_INCLUDE_DIR} library directory: ${MYSQL_LIB_DIR}")
message(STATUS "Use MariaDB for MySQL Support")
include_directories(${MYSQL_INCLUDE_DIR} )
link_directories(${MYSQL_LIB_DIR})
else ((MARIADB_INCLUDE_DIR OR MYSQL_INCLUDE_DIR) AND MARIADB_LIB)
message(STATUS "Couldn't find MySQL or MariaDB")
endif (MYSQL_INCLUDE_DIR AND MYSQL_LIB)

View File

@ -107,7 +107,6 @@ cp ${POCO_BASE}/CMakeLists.txt ${target}
mkdir -p ${target}/build/config
mkdir -p ${target}/build/rules
mkdir -p ${target}/build/script
mkdir -p ${target}/build/vms
mkdir -p ${target}/build/vxconfig
cp ${POCO_BASE}/build/config/* ${target}/build/config
@ -145,9 +144,9 @@ cp ${POCO_BASE}/CppUnit/*.vcxproj ${target}/CppUnit >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/*.vcxproj.filters ${target}/CppUnit >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/*.vcxproj.user ${target}/CppUnit >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/Makefile ${target}/CppUnit >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/*.vmsbuild ${target}/CppUnit >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/*.vxbuild ${target}/CppUnit >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/*.progen ${target}/CppUnit >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/CMakeLists.txt ${target}/CppUnit >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/WinTestRunner/include/WinTestRunner/* ${target}/CppUnit/WinTestRunner/include/WinTestRunner >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/WinTestRunner/src/* ${target}/CppUnit/WinTestRunner/src >/dev/null 2>&1
@ -158,6 +157,7 @@ cp ${POCO_BASE}/CppUnit/WinTestRunner/*.vcxproj ${target}/CppUnit/WinTestRunner
cp ${POCO_BASE}/CppUnit/WinTestRunner/*.vcxproj.filters ${target}/CppUnit/WinTestRunner >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/WinTestRunner/*.vcxproj.user ${target}/CppUnit/WinTestRunner >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/WinTestRunner/*.progen ${target}/CppUnit/WinTestRunner >/dev/null 2>&1
cp ${POCO_BASE}/CppUnit/WinTestRunner/CMakeLists.txt ${target}/CppUnit/WinTestRunner >/dev/null 2>&1
#