You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2012/06/28 11:15:39 UTC

svn commit: r1354874 [10/14] - in /qpid/branches/java-config-and-management: ./ qpid/ qpid/bin/ qpid/cpp/ qpid/cpp/bindings/ qpid/cpp/bindings/qmf/ruby/ qpid/cpp/bindings/qpid/python/ qpid/cpp/bindings/qpid/ruby/ qpid/cpp/bindings/qpid/ruby/features/ q...

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/store/ms-clfs/TransactionLog.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/store/ms-clfs/TransactionLog.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/store/ms-clfs/TransactionLog.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/store/ms-clfs/TransactionLog.cpp Thu Jun 28 09:14:52 2012
@@ -33,6 +33,10 @@
 #include "Transaction.h"
 #include "Lsn.h"
 
+namespace qpid {
+namespace store {
+namespace ms_clfs {
+
 namespace {
 
 // Structures that hold log records. Each has a type field at the start.
@@ -95,10 +99,6 @@ struct TransactionDelete {
 
 }   // namespace
 
-namespace qpid {
-namespace store {
-namespace ms_clfs {
-
 void
 TransactionLog::initialize()
 {

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp Thu Jun 28 09:14:52 2012
@@ -23,6 +23,7 @@
 #include "qpid/sys/AsynchIO.h"
 #include "qpid/sys/Socket.h"
 #include "qpid/sys/SecuritySettings.h"
+#include "qpid/sys/Timer.h"
 #include "qpid/framing/AMQP_HighestVersion.h"
 #include "qpid/framing/ProtocolInitiation.h"
 #include "qpid/log/Statement.h"
@@ -41,7 +42,25 @@ struct Buff : public AsynchIO::BufferBas
     { delete [] bytes;}
 };
 
-AsynchIOHandler::AsynchIOHandler(std::string id, ConnectionCodec::Factory* f) :
+struct ProtocolTimeoutTask : public sys::TimerTask {
+    AsynchIOHandler& handler;
+    std::string id;
+
+    ProtocolTimeoutTask(const std::string& i, const Duration& timeout, AsynchIOHandler& h) :
+        TimerTask(timeout, "ProtocolTimeout"),
+        handler(h),
+        id(i)
+    {}
+
+    void fire() {
+        // If this fires it means that we didn't negotiate the connection in the timeout period
+        // Schedule closing the connection for the io thread
+        QPID_LOG(error, "Connection " << id << " No protocol received closing");
+        handler.abort();
+    }
+};
+
+AsynchIOHandler::AsynchIOHandler(const std::string& id, ConnectionCodec::Factory* f) :
     identifier(id),
     aio(0),
     factory(f),
@@ -54,12 +73,18 @@ AsynchIOHandler::AsynchIOHandler(std::st
 AsynchIOHandler::~AsynchIOHandler() {
     if (codec)
         codec->closed();
+    if (timeoutTimerTask)
+        timeoutTimerTask->cancel();
     delete codec;
 }
 
-void AsynchIOHandler::init(AsynchIO* a, int numBuffs) {
+void AsynchIOHandler::init(qpid::sys::AsynchIO* a, qpid::sys::Timer& timer, uint32_t maxTime, int numBuffs) {
     aio = a;
 
+    // Start timer for this connection
+    timeoutTimerTask = new ProtocolTimeoutTask(identifier, maxTime*TIME_MSEC, *this);
+    timer.add(timeoutTimerTask);
+
     // Give connection some buffers to use
     for (int i = 0; i < numBuffs; i++) {
         aio->queueReadBuffer(new Buff);
@@ -143,6 +168,9 @@ void AsynchIOHandler::readbuff(AsynchIO&
         framing::ProtocolInitiation protocolInit;
         if (protocolInit.decode(in)) {
             decoded = in.getPosition();
+            // We've just got the protocol negotiation so we can cancel the timeout for that
+            timeoutTimerTask->cancel();
+
             QPID_LOG(debug, "RECV [" << identifier << "]: INIT(" << protocolInit << ")");
             try {
                 codec = factory->create(protocolInit.getVersion(), *this, identifier, SecuritySettings());
@@ -202,6 +230,10 @@ void AsynchIOHandler::idle(AsynchIO&){
     if (isClient && codec == 0) {
         codec = factory->create(*this, identifier, SecuritySettings());
         write(framing::ProtocolInitiation(codec->getVersion()));
+        // We've just sent the protocol negotiation so we can cancel the timeout for that
+        // This is not ideal, because we've not received anything yet, but heartbeats will
+        // be active soon
+        timeoutTimerTask->cancel();
         return;
     }
     if (codec == 0) return;

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/AsynchIOHandler.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/AsynchIOHandler.h?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/AsynchIOHandler.h (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/AsynchIOHandler.h Thu Jun 28 09:14:52 2012
@@ -27,6 +27,8 @@
 #include "qpid/sys/Mutex.h"
 #include "qpid/CommonImportExport.h"
 
+#include <boost/intrusive_ptr.hpp>
+
 namespace qpid {
 
 namespace framing {
@@ -38,6 +40,8 @@ namespace sys {
 class AsynchIO;
 struct AsynchIOBufferBase;
 class Socket;
+class Timer;
+class TimerTask;
 
 class AsynchIOHandler : public OutputControl {
     std::string identifier;
@@ -49,13 +53,14 @@ class AsynchIOHandler : public OutputCon
     AtomicValue<int32_t> readCredit;
     static const int32_t InfiniteCredit = -1;
     Mutex creditLock;
+    boost::intrusive_ptr<sys::TimerTask> timeoutTimerTask;
 
     void write(const framing::ProtocolInitiation&);
 
   public:
-    QPID_COMMON_EXTERN AsynchIOHandler(std::string id, ConnectionCodec::Factory* f);
+    QPID_COMMON_EXTERN AsynchIOHandler(const std::string& id, qpid::sys::ConnectionCodec::Factory* f );
     QPID_COMMON_EXTERN ~AsynchIOHandler();
-    QPID_COMMON_EXTERN void init(AsynchIO* a, int numBuffs);
+    QPID_COMMON_EXTERN void init(AsynchIO* a, Timer& timer, uint32_t maxTime, int numBuffs);
 
     QPID_COMMON_INLINE_EXTERN void setClient() { isClient = true; }
 

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/SslPlugin.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/SslPlugin.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/SslPlugin.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/SslPlugin.cpp Thu Jun 28 09:14:52 2012
@@ -39,6 +39,8 @@
 namespace qpid {
 namespace sys {
 
+class Timer;
+
 using namespace qpid::sys::ssl;
 
 struct SslServerOptions : ssl::SslOptions
@@ -68,6 +70,8 @@ class SslProtocolFactoryTmpl : public Pr
 
     typedef SslAcceptorTmpl<T> SslAcceptor;
 
+    Timer& brokerTimer;
+    uint32_t maxNegotiateTime;
     const bool tcpNoDelay;
     T listener;
     const uint16_t listeningPort;
@@ -75,7 +79,7 @@ class SslProtocolFactoryTmpl : public Pr
     bool nodict;
 
   public:
-    SslProtocolFactoryTmpl(const SslServerOptions&, int backlog, bool nodelay);
+    SslProtocolFactoryTmpl(const SslServerOptions&, int backlog, bool nodelay, Timer& timer, uint32_t maxTime);
     void accept(Poller::shared_ptr, ConnectionCodec::Factory*);
     void connect(Poller::shared_ptr, const std::string& host, const std::string& port,
                  ConnectionCodec::Factory*,
@@ -132,16 +136,18 @@ static struct SslPlugin : public Plugin 
                 try {
                     ssl::initNSS(options, true);
                     nssInitialized = true;
-                    
+
                     const broker::Broker::Options& opts = broker->getOptions();
 
                     ProtocolFactory::shared_ptr protocol(options.multiplex ?
                         static_cast<ProtocolFactory*>(new SslMuxProtocolFactory(options,
                                                   opts.connectionBacklog,
-                                                  opts.tcpNoDelay)) :
+                                                  opts.tcpNoDelay,
+                                                  broker->getTimer(), opts.maxNegotiateTime)) :
                         static_cast<ProtocolFactory*>(new SslProtocolFactory(options,
                                                opts.connectionBacklog,
-                                               opts.tcpNoDelay)));
+                                               opts.tcpNoDelay,
+                                               broker->getTimer(), opts.maxNegotiateTime)));
                     QPID_LOG(notice, "Listening for " <<
                                      (options.multiplex ? "SSL or TCP" : "SSL") <<
                                      " connections on TCP port " <<
@@ -156,14 +162,16 @@ static struct SslPlugin : public Plugin 
 } sslPlugin;
 
 template <class T>
-SslProtocolFactoryTmpl<T>::SslProtocolFactoryTmpl(const SslServerOptions& options, int backlog, bool nodelay) :
+SslProtocolFactoryTmpl<T>::SslProtocolFactoryTmpl(const SslServerOptions& options, int backlog, bool nodelay, Timer& timer, uint32_t maxTime) :
+    brokerTimer(timer),
+    maxNegotiateTime(maxTime),
     tcpNoDelay(nodelay), listeningPort(listener.listen(options.port, backlog, options.certName, options.clientAuth)),
     nodict(options.nodict)
 {}
 
 void SslEstablished(Poller::shared_ptr poller, const qpid::sys::SslSocket& s,
                     ConnectionCodec::Factory* f, bool isClient,
-                    bool tcpNoDelay, bool nodict) {
+                    Timer& timer, uint32_t maxTime, bool tcpNoDelay, bool nodict) {
     qpid::sys::ssl::SslHandler* async = new qpid::sys::ssl::SslHandler(s.getFullAddress(), f, nodict);
 
     if (tcpNoDelay) {
@@ -183,7 +191,7 @@ void SslEstablished(Poller::shared_ptr p
                                  boost::bind(&qpid::sys::ssl::SslHandler::nobuffs, async, _1),
                                  boost::bind(&qpid::sys::ssl::SslHandler::idle, async, _1));
 
-    async->init(aio, 4);
+    async->init(aio,timer, maxTime, 4);
     aio->start(poller);
 }
 
@@ -192,7 +200,7 @@ void SslProtocolFactory::established(Pol
                                      ConnectionCodec::Factory* f, bool isClient) {
     const SslSocket *sslSock = dynamic_cast<const SslSocket*>(&s);
 
-    SslEstablished(poller, *sslSock, f, isClient, tcpNoDelay, nodict);
+    SslEstablished(poller, *sslSock, f, isClient, brokerTimer, maxNegotiateTime, tcpNoDelay, nodict);
 }
 
 template <class T>
@@ -216,7 +224,7 @@ void SslMuxProtocolFactory::established(
     const SslSocket *sslSock = dynamic_cast<const SslSocket*>(&s);
 
     if (sslSock) {
-        SslEstablished(poller, *sslSock, f, isClient, tcpNoDelay, nodict);
+        SslEstablished(poller, *sslSock, f, isClient, brokerTimer, maxNegotiateTime, tcpNoDelay, nodict);
         return;
     }
 
@@ -239,7 +247,7 @@ void SslMuxProtocolFactory::established(
        boost::bind(&AsynchIOHandler::nobuffs, async, _1),
        boost::bind(&AsynchIOHandler::idle, async, _1));
 
-    async->init(aio, 4);
+    async->init(aio, brokerTimer, maxNegotiateTime, 4);
     aio->start(poller);
 }
 

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp Thu Jun 28 09:14:52 2012
@@ -36,14 +36,21 @@
 namespace qpid {
 namespace sys {
 
+class Timer;
+
 class AsynchIOProtocolFactory : public ProtocolFactory {
-    const bool tcpNoDelay;
     boost::ptr_vector<Socket> listeners;
     boost::ptr_vector<AsynchAcceptor> acceptors;
+    Timer& brokerTimer;
+    uint32_t maxNegotiateTime;
     uint16_t listeningPort;
+    const bool tcpNoDelay;
 
   public:
-    AsynchIOProtocolFactory(const std::string& host, const std::string& port, int backlog, bool nodelay, bool shouldListen);
+    AsynchIOProtocolFactory(const std::string& host, const std::string& port,
+                            int backlog, bool nodelay,
+                            Timer& timer, uint32_t maxTime,
+                            bool shouldListen);
     void accept(Poller::shared_ptr, ConnectionCodec::Factory*);
     void connect(Poller::shared_ptr, const std::string& host, const std::string& port,
                  ConnectionCodec::Factory*,
@@ -90,6 +97,7 @@ static class TCPIOPlugin : public Plugin
                     "", boost::lexical_cast<std::string>(opts.port),
                     opts.connectionBacklog,
                     opts.tcpNoDelay,
+                    broker->getTimer(), opts.maxNegotiateTime,
                     shouldListen));
 
             if (shouldListen) {
@@ -101,7 +109,12 @@ static class TCPIOPlugin : public Plugin
     }
 } tcpPlugin;
 
-AsynchIOProtocolFactory::AsynchIOProtocolFactory(const std::string& host, const std::string& port, int backlog, bool nodelay, bool shouldListen) :
+AsynchIOProtocolFactory::AsynchIOProtocolFactory(const std::string& host, const std::string& port,
+                                                 int backlog, bool nodelay,
+                                                 Timer& timer, uint32_t maxTime,
+                                                 bool shouldListen) :
+    brokerTimer(timer),
+    maxNegotiateTime(maxTime),
     tcpNoDelay(nodelay)
 {
     if (!shouldListen) {
@@ -153,7 +166,7 @@ void AsynchIOProtocolFactory::establishe
        boost::bind(&AsynchIOHandler::nobuffs, async, _1),
        boost::bind(&AsynchIOHandler::idle, async, _1));
 
-    async->init(aio, 4);
+    async->init(aio, brokerTimer, maxNegotiateTime, 4);
     aio->start(poller);
 }
 

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp Thu Jun 28 09:14:52 2012
@@ -18,6 +18,7 @@
  * under the License.
  *
  */
+#include <unistd.h>
 #include "qpid/sys/cyrus/CyrusSecurityLayer.h"
 #include <algorithm>
 #include "qpid/framing/reply_exceptions.h"

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/AsynchIO.cpp Thu Jun 28 09:14:52 2012
@@ -41,7 +41,9 @@
 #include <boost/bind.hpp>
 #include <boost/lexical_cast.hpp>
 
-using namespace qpid::sys;
+namespace qpid {
+namespace sys {
+namespace posix {
 
 namespace {
 
@@ -71,10 +73,6 @@ __thread int64_t threadMaxIoTimeNs = 2 *
 /*
  * Asynch Acceptor
  */
-namespace qpid {
-namespace sys {
-namespace posix {
-
 class AsynchAcceptor : public qpid::sys::AsynchAcceptor {
 public:
     AsynchAcceptor(const Socket& s, AsynchAcceptor::Callback callback);

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/LockFile.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/LockFile.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/LockFile.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/LockFile.cpp Thu Jun 28 09:14:52 2012
@@ -46,7 +46,7 @@ LockFile::LockFile(const std::string& pa
     errno = 0;
     int flags=create ? O_WRONLY|O_CREAT|O_NOFOLLOW : O_RDWR;
     int fd = ::open(path.c_str(), flags, 0644);
-    if (fd < 0) throw ErrnoException("Cannot open " + path, errno);
+    if (fd < 0) throw ErrnoException("Cannot open lock file " + path, errno);
     if (::lockf(fd, F_TLOCK, 0) < 0) {
         ::close(fd);
         throw ErrnoException("Cannot lock " + path, errno);

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/MemStat.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/MemStat.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/MemStat.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/MemStat.cpp Thu Jun 28 09:14:52 2012
@@ -20,6 +20,7 @@
  */
 
 #include "qpid/sys/MemStat.h"
+
 #include <malloc.h>
 
 void qpid::sys::MemStat::loadMemInfo(qmf::org::apache::qpid::broker::Memory* object)
@@ -35,4 +36,3 @@ void qpid::sys::MemStat::loadMemInfo(qmf
     object->set_malloc_keepcost(info.keepcost);
 }
 
-

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/PollableCondition.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/PollableCondition.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/PollableCondition.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/PollableCondition.cpp Thu Jun 28 09:14:52 2012
@@ -1,6 +1,3 @@
-#ifndef QPID_SYS_LINUX_POLLABLECONDITION_CPP
-#define QPID_SYS_LINUX_POLLABLECONDITION_CPP
-
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -120,5 +117,3 @@ void PollableCondition::set() { impl->se
 void PollableCondition::clear() { impl->clear(); }
 
 }} // namespace qpid::sys
-
-#endif  /*!QPID_SYS_LINUX_POLLABLECONDITION_CPP*/

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp Thu Jun 28 09:14:52 2012
@@ -35,14 +35,16 @@ namespace sys {
 SocketAddress::SocketAddress(const std::string& host0, const std::string& port0) :
     host(host0),
     port(port0),
-    addrInfo(0)
+    addrInfo(0),
+    currentAddrInfo(0)
 {
 }
 
 SocketAddress::SocketAddress(const SocketAddress& sa) :
     host(sa.host),
     port(sa.port),
-    addrInfo(0)
+    addrInfo(0),
+    currentAddrInfo(0)
 {
 }
 

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp Thu Jun 28 09:14:52 2012
@@ -18,10 +18,11 @@
  *
  */
 
+#include "qpid/log/Statement.h"
 #include "qpid/sys/SystemInfo.h"
-
 #include "qpid/sys/posix/check.h"
-
+#include <set>
+#include <arpa/inet.h>
 #include <sys/ioctl.h>
 #include <sys/utsname.h>
 #include <sys/types.h> // For FreeBSD
@@ -59,48 +60,97 @@ bool SystemInfo::getLocalHostname (Addre
     return true;
 }
 
-static const string LOCALHOST("127.0.0.1");
+static const string LOOPBACK("127.0.0.1");
 static const string TCP("tcp");
 
+// Test IPv4 address for loopback
+inline bool IN_IS_ADDR_LOOPBACK(const ::in_addr* a) {
+    return ((ntohl(a->s_addr) & 0xff000000) == 0x7f000000);
+}
+
+inline bool isLoopback(const ::sockaddr* addr) {
+    switch (addr->sa_family) {
+        case AF_INET: return IN_IS_ADDR_LOOPBACK(&((const ::sockaddr_in*)(const void*)addr)->sin_addr);
+        case AF_INET6: return IN6_IS_ADDR_LOOPBACK(&((const ::sockaddr_in6*)(const void*)addr)->sin6_addr);
+        default: return false;
+    }
+}
+
 void SystemInfo::getLocalIpAddresses (uint16_t port,
                                       std::vector<Address> &addrList) {
     ::ifaddrs* ifaddr = 0;
     QPID_POSIX_CHECK(::getifaddrs(&ifaddr));
     for (::ifaddrs* ifap = ifaddr; ifap != 0; ifap = ifap->ifa_next) {
         if (ifap->ifa_addr == 0) continue;
-
+        if (isLoopback(ifap->ifa_addr)) continue;
         int family = ifap->ifa_addr->sa_family;
         switch (family) {
-        case AF_INET: {
-            char dispName[NI_MAXHOST];
-            int rc = ::getnameinfo(
-                        ifap->ifa_addr,
-                        (family == AF_INET)
-                            ? sizeof(struct sockaddr_in)
-                            : sizeof(struct sockaddr_in6),
-                        dispName, sizeof(dispName),
-                        0, 0, NI_NUMERICHOST);
-            if (rc != 0) {
-                throw QPID_POSIX_ERROR(rc);
+            case AF_INET6: {
+                // Ignore link local addresses as:
+                // * The scope id is illegal in URL syntax
+                // * Clients won't be able to use a link local address
+                //   without adding their own (potentially different) scope id
+                sockaddr_in6* sa6 = (sockaddr_in6*)(ifap->ifa_addr);
+                if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr)) break;
+                // Fallthrough
             }
-            string addr(dispName);
-            if (addr != LOCALHOST) {
-                addrList.push_back(Address(TCP, addr, port));
-            }
-            break;
-        }
-        // TODO: Url parsing currently can't cope with IPv6 addresses so don't return them
-        // when it can cope move this line to above "case AF_INET:"
-        case AF_INET6:
-        default:
+            case AF_INET: {
+              char dispName[NI_MAXHOST];
+              int rc = ::getnameinfo(
+                  ifap->ifa_addr,
+                  (family == AF_INET)
+                  ? sizeof(struct sockaddr_in)
+                  : sizeof(struct sockaddr_in6),
+                  dispName, sizeof(dispName),
+                  0, 0, NI_NUMERICHOST);
+              if (rc != 0) {
+                  throw QPID_POSIX_ERROR(rc);
+              }
+              string addr(dispName);
+              addrList.push_back(Address(TCP, addr, port));
+              break;
+          }
+          default:
             continue;
         }
     }
-    freeifaddrs(ifaddr);
+    ::freeifaddrs(ifaddr);
 
     if (addrList.empty()) {
-        addrList.push_back(Address(TCP, LOCALHOST, port));
+        addrList.push_back(Address(TCP, LOOPBACK, port));
+    }
+}
+
+namespace {
+struct AddrInfo {
+    struct addrinfo* ptr;
+    AddrInfo(const std::string& host) : ptr(0) {
+        if (::getaddrinfo(host.c_str(), NULL, NULL, &ptr) != 0)
+            ptr = 0;
+    }
+    ~AddrInfo() { if (ptr) ::freeaddrinfo(ptr); }
+};
+}
+
+bool SystemInfo::isLocalHost(const std::string& host) {
+    std::vector<Address> myAddrs;
+    getLocalIpAddresses(0, myAddrs);
+    std::set<string> localHosts;
+    for (std::vector<Address>::const_iterator i = myAddrs.begin(); i != myAddrs.end(); ++i)
+        localHosts.insert(i->host);
+    // Resolve host
+    AddrInfo ai(host);
+    if (!ai.ptr) return false;
+    for (struct addrinfo *res = ai.ptr; res != NULL; res = res->ai_next) {
+        if (isLoopback(res->ai_addr)) return true;
+        // Get string form of IP addr
+        char addr[NI_MAXHOST] = "";
+        int error = ::getnameinfo(res->ai_addr, res->ai_addrlen, addr, NI_MAXHOST, NULL, 0,
+                                  NI_NUMERICHOST | NI_NUMERICSERV);
+        if (error) return false;
+        if (localHosts.find(addr) != localHosts.end()) return true;
     }
+    return false;
 }
 
 void SystemInfo::getSystemId (std::string &osName,

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslHandler.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslHandler.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslHandler.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslHandler.cpp Thu Jun 28 09:14:52 2012
@@ -19,9 +19,9 @@
  *
  */
 #include "qpid/sys/ssl/SslHandler.h"
-
 #include "qpid/sys/ssl/SslIo.h"
 #include "qpid/sys/ssl/SslSocket.h"
+#include "qpid/sys/Timer.h"
 #include "qpid/framing/AMQP_HighestVersion.h"
 #include "qpid/framing/ProtocolInitiation.h"
 #include "qpid/log/Statement.h"
@@ -42,6 +42,24 @@ struct Buff : public SslIO::BufferBase {
     { delete [] bytes;}
 };
 
+struct ProtocolTimeoutTask : public sys::TimerTask {
+    SslHandler& handler;
+    std::string id;
+
+    ProtocolTimeoutTask(const std::string& i, const Duration& timeout, SslHandler& h) :
+    TimerTask(timeout, "ProtocolTimeout"),
+        handler(h),
+        id(i)
+    {}
+
+    void fire() {
+        // If this fires it means that we didn't negotiate the connection in the timeout period
+        // Schedule closing the connection for the io thread
+        QPID_LOG(error, "Connection " << id << " No protocol received closing");
+        handler.abort();
+    }
+};
+
 SslHandler::SslHandler(std::string id, ConnectionCodec::Factory* f, bool _nodict) :
     identifier(id),
     aio(0),
@@ -55,12 +73,18 @@ SslHandler::SslHandler(std::string id, C
 SslHandler::~SslHandler() {
     if (codec)
         codec->closed();
+    if (timeoutTimerTask)
+        timeoutTimerTask->cancel();
     delete codec;
 }
 
-void SslHandler::init(SslIO* a, int numBuffs) {
+void SslHandler::init(SslIO* a, Timer& timer, uint32_t maxTime, int numBuffs) {
     aio = a;
 
+    // Start timer for this connection
+    timeoutTimerTask = new ProtocolTimeoutTask(identifier, maxTime*TIME_MSEC, *this);
+    timer.add(timeoutTimerTask);
+
     // Give connection some buffers to use
     for (int i = 0; i < numBuffs; i++) {
         aio->queueReadBuffer(new Buff);
@@ -80,8 +104,10 @@ void SslHandler::write(const framing::Pr
 }
 
 void SslHandler::abort() {
-    // TODO: can't implement currently as underlying functionality not implemented
-    // aio->requestCallback(boost::bind(&SslHandler::eof, this, _1));
+    // Don't disconnect if we're already disconnecting
+    if (!readError) {
+        aio->requestCallback(boost::bind(&SslHandler::eof, this, _1));
+    }
 }
 void SslHandler::activateOutput() {
     aio->notifyPendingWrite();
@@ -109,6 +135,9 @@ void SslHandler::readbuff(SslIO& , SslIO
         framing::Buffer in(buff->bytes+buff->dataStart, buff->dataCount);
         framing::ProtocolInitiation protocolInit;
         if (protocolInit.decode(in)) {
+            // We've just got the protocol negotiation so we can cancel the timeout for that
+            timeoutTimerTask->cancel();
+
             decoded = in.getPosition();
             QPID_LOG(debug, "RECV [" << identifier << "]: INIT(" << protocolInit << ")");
             try {
@@ -169,6 +198,10 @@ void SslHandler::idle(SslIO&){
     if (isClient && codec == 0) {
         codec = factory->create(*this, identifier, getSecuritySettings(aio));
         write(framing::ProtocolInitiation(codec->getVersion()));
+        // We've just sent the protocol negotiation so we can cancel the timeout for that
+        // This is not ideal, because we've not received anything yet, but heartbeats will
+        // be active soon
+        timeoutTimerTask->cancel();
         return;
     }
     if (codec == 0) return;

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslHandler.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslHandler.h?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslHandler.h (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslHandler.h Thu Jun 28 09:14:52 2012
@@ -25,6 +25,8 @@
 #include "qpid/sys/ConnectionCodec.h"
 #include "qpid/sys/OutputControl.h"
 
+#include <boost/intrusive_ptr.hpp>
+
 namespace qpid {
 
 namespace framing {
@@ -32,6 +34,10 @@ namespace framing {
 }
 
 namespace sys {
+
+class Timer;
+class TimerTask;
+
 namespace ssl {
 
 class SslIO;
@@ -46,6 +52,7 @@ class SslHandler : public OutputControl 
     bool readError;
     bool isClient;
     bool nodict;
+    boost::intrusive_ptr<sys::TimerTask> timeoutTimerTask;
 
     void write(const framing::ProtocolInitiation&);
     qpid::sys::SecuritySettings getSecuritySettings(SslIO* aio);
@@ -53,7 +60,7 @@ class SslHandler : public OutputControl 
   public:
     SslHandler(std::string id, ConnectionCodec::Factory* f, bool nodict);
     ~SslHandler();
-    void init(SslIO* a, int numBuffs);
+    void init(SslIO* a, Timer& timer, uint32_t maxTime, int numBuffs);
 
     void setClient() { isClient = true; }
 

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslIo.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslIo.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslIo.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslIo.cpp Thu Jun 28 09:14:52 2012
@@ -37,8 +37,9 @@
 
 #include <boost/bind.hpp>
 
-using namespace qpid::sys;
-using namespace qpid::sys::ssl;
+namespace qpid {
+namespace sys {
+namespace ssl {
 
 namespace {
 
@@ -256,6 +257,18 @@ void SslIO::queueWriteClose() {
     DispatchHandle::rewatchWrite();
 }
 
+void SslIO::requestCallback(RequestCallback callback) {
+    // TODO creating a function object every time isn't all that
+    // efficient - if this becomes heavily used do something better (what?)
+    assert(callback);
+    DispatchHandle::call(boost::bind(&SslIO::requestedCall, this, callback));
+}
+
+void SslIO::requestedCall(RequestCallback callback) {
+    assert(callback);
+    callback(*this);
+}
+
 /** Return a queued buffer if there are enough
  * to spare
  */
@@ -448,3 +461,5 @@ SecuritySettings SslIO::getSecuritySetti
     settings.authid = socket.getClientAuthId();
     return settings;
 }
+
+}}}

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslIo.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslIo.h?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslIo.h (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/ssl/SslIo.h Thu Jun 28 09:14:52 2012
@@ -125,6 +125,7 @@ public:
     typedef boost::function2<void, SslIO&, const SslSocket&> ClosedCallback;
     typedef boost::function1<void, SslIO&> BuffersEmptyCallback;
     typedef boost::function1<void, SslIO&> IdleCallback;
+    typedef boost::function1<void, SslIO&> RequestCallback;
 
 
 private:
@@ -159,6 +160,7 @@ public:
     void notifyPendingWrite();
     void queueWriteClose();
     bool writeQueueEmpty() { return writeQueue.empty(); }
+    void requestCallback(RequestCallback);
     BufferBase* getQueuedBuffer();
 
     qpid::sys::SecuritySettings getSecuritySettings();
@@ -168,6 +170,7 @@ private:
     void readable(qpid::sys::DispatchHandle& handle);
     void writeable(qpid::sys::DispatchHandle& handle);
     void disconnected(qpid::sys::DispatchHandle& handle);
+    void requestedCall(RequestCallback);
     void close(qpid::sys::DispatchHandle& handle);
 };
 

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/unordered_map.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/unordered_map.h?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/unordered_map.h (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/unordered_map.h Thu Jun 28 09:14:52 2012
@@ -23,6 +23,8 @@
 
 #ifdef _MSC_VER
 #  include <unordered_map>
+#elif defined(__SUNPRO_CC)
+#  include <boost/tr1/unordered_map.hpp>
 #else
 #  include <tr1/unordered_map>
 #endif /* _MSC_VER */

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp Thu Jun 28 09:14:52 2012
@@ -291,6 +291,8 @@ private:
     volatile LONG opsInProgress;
     // Is there a write in progress?
     volatile bool writeInProgress;
+    // Or a read?
+    volatile bool readInProgress;
     // Deletion requested, but there are callbacks in progress.
     volatile bool queuedDelete;
     // Socket close requested, but there are operations in progress.
@@ -344,6 +346,11 @@ private:
      * Called when there's a completion to process.
      */
     void completion(AsynchIoResult *result);
+
+    /**
+     * Helper function to facilitate the close operation
+     */
+    void cancelRead();
 };
 
 // This is used to encapsulate pure callbacks into a handle
@@ -372,6 +379,7 @@ AsynchIO::AsynchIO(const Socket& s,
     socket(s),
     opsInProgress(0),
     writeInProgress(false),
+    readInProgress(false),
     queuedDelete(false),
     queuedClose(false),
     working(false) {
@@ -389,21 +397,24 @@ AsynchIO::~AsynchIO() {
 }
 
 void AsynchIO::queueForDeletion() {
-    queuedDelete = true;
-    if (opsInProgress > 0) {
-        QPID_LOG(info, "Delete AsynchIO queued; ops in progress");
-        // AsynchIOHandler calls this then deletes itself; don't do any more
-        // callbacks.
-        readCallback = 0;
-        eofCallback = 0;
-        disCallback = 0;
-        closedCallback = 0;
-        emptyCallback = 0;
-        idleCallback = 0;
-    }
-    else {
-        delete this;
+    {
+        ScopedLock<Mutex> l(completionLock);
+        assert(!queuedDelete);
+        queuedDelete = true;
+        if (working || opsInProgress > 0) {
+            QPID_LOG(info, "Delete AsynchIO queued; ops in progress");
+            // AsynchIOHandler calls this then deletes itself; don't do any more
+            // callbacks.
+            readCallback = 0;
+            eofCallback = 0;
+            disCallback = 0;
+            closedCallback = 0;
+            emptyCallback = 0;
+            idleCallback = 0;
+            return;
+        }
     }
+    delete this;
 }
 
 void AsynchIO::start(Poller::shared_ptr poller0) {
@@ -451,9 +462,14 @@ void AsynchIO::notifyPendingWrite() {
 }
 
 void AsynchIO::queueWriteClose() {
-    queuedClose = true;
-    if (!writeInProgress)
-        notifyPendingWrite();
+    {
+        ScopedLock<Mutex> l(completionLock);
+        queuedClose = true;
+        if (working || writeInProgress)
+            // no need to summon an IO thread
+            return;
+    }
+    notifyPendingWrite();
 }
 
 bool AsynchIO::writeQueueEmpty() {
@@ -466,7 +482,7 @@ bool AsynchIO::writeQueueEmpty() {
  * called when the read is complete and data is available.
  */
 void AsynchIO::startReading() {
-    if (queuedDelete)
+    if (queuedDelete || queuedClose)
         return;
 
     // (Try to) get a buffer; look on the front since there may be an
@@ -489,6 +505,7 @@ void AsynchIO::startReading() {
                                  readCount);
         DWORD bytesReceived = 0, flags = 0;
         InterlockedIncrement(&opsInProgress);
+        readInProgress = true;
         int status = WSARecv(toSocketHandle(socket),
                              const_cast<LPWSABUF>(result->getWSABUF()), 1,
                              &bytesReceived,
@@ -616,17 +633,19 @@ void AsynchIO::close(void) {
 void AsynchIO::readComplete(AsynchReadResult *result) {
     int status = result->getStatus();
     size_t bytes = result->getTransferred();
+    readInProgress = false;
     if (status == 0 && bytes > 0) {
-        bool restartRead = true;     // May not if receiver doesn't want more
         if (readCallback)
             readCallback(*this, result->getBuff());
-        if (restartRead)
-            startReading();
+        startReading();
     }
     else {
         // No data read, so put the buffer back. It may be partially filled,
         // so "unread" it back to the front of the queue.
         unread(result->getBuff());
+        if (queuedClose) {
+            return; // Expected from cancelRead()
+        }
         notifyEof();
         if (status != 0)
         {
@@ -682,6 +701,8 @@ void AsynchIO::writeComplete(AsynchWrite
 }
 
 void AsynchIO::completion(AsynchIoResult *result) {
+    bool closing = false;
+    bool deleting = false;
     {
         ScopedLock<Mutex> l(completionLock);
         if (working) {
@@ -713,6 +734,8 @@ void AsynchIO::completion(AsynchIoResult
                 delete result;
                 result = 0;
                 InterlockedDecrement(&opsInProgress);
+                if (queuedClose && opsInProgress == 1 && readInProgress)
+                    cancelRead();
             }
             // Lock is held again.
             if (completionQueue.empty())
@@ -721,17 +744,40 @@ void AsynchIO::completion(AsynchIoResult
             completionQueue.pop();
         }
         working = false;
+        if (opsInProgress == 0) {
+            closing = queuedClose;
+            deleting = queuedDelete;
+        }
     }
     // Lock released; ok to close if ops are done and close requested.
     // Layer above will call back to queueForDeletion() if it hasn't
     // already been done. If it already has, go ahead and delete.
-    if (opsInProgress == 0) {
-        if (queuedClose)
-            // close() may cause a delete; don't trust 'this' on return
-            close();
-        else if (queuedDelete)
-            delete this;
-    }
+    if (deleting)
+        delete this;
+    else if (closing)
+        // close() may cause a delete; don't trust 'this' on return
+        close();
+}
+
+/*
+ * NOTE - this method must be called in the same context as other completions,
+ * so that the resulting readComplete, and final AsynchIO::close() is serialized
+ * after this method returns.
+ */
+void AsynchIO::cancelRead() {
+    if (queuedDelete)
+        return;                 // socket already deleted
+    else {
+        ScopedLock<Mutex> l(completionLock);;
+        if (!completionQueue.empty())
+            return;             // process it; come back later if necessary
+    }
+    // Cancel outstanding read and force to completion.  Otherwise, on a faulty
+    // physical link, the pending read can remain uncompleted indefinitely.
+    // Draining the pending read will result in the official close (and
+    // notifyClosed).  CancelIoEX() is the natural choice, but not available in
+    // XP, so we make do with closesocket().
+    socket.close();
 }
 
 } // namespace windows

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/IocpPoller.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/IocpPoller.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/IocpPoller.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/IocpPoller.cpp Thu Jun 28 09:14:52 2012
@@ -96,6 +96,7 @@ void Poller::shutdown() {
     // Allow sloppy code to shut us down more than once.
     if (impl->isShutdown)
         return;
+    impl->isShutdown = true;
     ULONG_PTR key = 1;    // Tell wait() it's a shutdown, not I/O
     PostQueuedCompletionStatus(impl->iocp, 0, key, 0);
 }
@@ -110,7 +111,7 @@ bool Poller::interrupt(PollerHandle&) {
 }
 
 void Poller::run() {
-    do {
+    while (!impl->isShutdown) {
         Poller::Event event = this->wait();
 
         // Handle shutdown
@@ -124,7 +125,7 @@ void Poller::run() {
           // This should be impossible
           assert(false);
         }
-    } while (true);
+    }
 }
 
 void Poller::monitorHandle(PollerHandle& handle, Direction dir) {

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/PollableCondition.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/PollableCondition.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/PollableCondition.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/PollableCondition.cpp Thu Jun 28 09:14:52 2012
@@ -1,6 +1,3 @@
-#ifndef QPID_SYS_WINDOWS_POLLABLECONDITION_CPP
-#define QPID_SYS_WINDOWS_POLLABLECONDITION_CPP
-
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -110,5 +107,3 @@ void PollableCondition::clear() {
 }
 
 }} // namespace qpid::sys
-
-#endif  /*!QPID_SYS_WINDOWS_POLLABLECONDITION_CPP*/

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/Socket.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/Socket.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/Socket.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/Socket.cpp Thu Jun 28 09:14:52 2012
@@ -32,6 +32,9 @@
 
 #include <winsock2.h>
 
+namespace qpid {
+namespace sys {
+
 // Need to initialize WinSock. Ideally, this would be a singleton or embedded
 // in some one-time initialization function. I tried boost singleton and could
 // not get it to compile (and others located in google had the same problem).
@@ -76,13 +79,6 @@ protected:
 
 static WinSockSetup setup;
 
-} /* namespace */
-
-namespace qpid {
-namespace sys {
-
-namespace {
-
 std::string getName(SOCKET fd, bool local)
 {
     ::sockaddr_storage name_s; // big enough for any socket address
@@ -270,14 +266,17 @@ int Socket::getError() const
 
 void Socket::setTcpNoDelay() const
 {
-    int flag = 1;
-    int result = setsockopt(impl->fd,
-                            IPPROTO_TCP,
-                            TCP_NODELAY,
-                            (char *)&flag,
-                            sizeof(flag));
-    QPID_WINSOCK_CHECK(result);
+    SOCKET& socket = impl->fd;
     nodelay = true;
+    if (socket != INVALID_SOCKET) {
+        int flag = 1;
+        int result = setsockopt(impl->fd,
+                                IPPROTO_TCP,
+                                TCP_NODELAY,
+                                (char *)&flag,
+                                sizeof(flag));
+        QPID_WINSOCK_CHECK(result);
+    }
 }
 
 inline IOHandlePrivate* IOHandlePrivate::getImpl(const qpid::sys::IOHandle &h)

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/SslAsynchIO.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/SslAsynchIO.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/SslAsynchIO.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/SslAsynchIO.cpp Thu Jun 28 09:14:52 2012
@@ -38,6 +38,10 @@
 #include <queue>
 #include <boost/bind.hpp>
 
+namespace qpid {
+namespace sys {
+namespace windows {
+
 namespace {
 
     /*
@@ -66,10 +70,6 @@ namespace {
     };
 }
 
-namespace qpid {
-namespace sys {
-namespace windows {
-
 SslAsynchIO::SslAsynchIO(const qpid::sys::Socket& s,
                          CredHandle hCred,
                          ReadCallback rCb,

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp Thu Jun 28 09:14:52 2012
@@ -23,9 +23,11 @@
 #  define _WIN32_WINNT 0x0501
 #endif
 
-#include "qpid/sys/IntegerTypes.h"
 #include "qpid/sys/SystemInfo.h"
+#include "qpid/sys/IntegerTypes.h"
+#include "qpid/Exception.h"
 
+#include <assert.h>
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #include <windows.h>
@@ -93,6 +95,12 @@ void SystemInfo::getLocalIpAddresses (ui
     }
 }
 
+bool SystemInfo::isLocalHost(const std::string& candidateHost) {
+    // FIXME aconway 2012-05-03: not implemented.
+    assert(0);
+    throw Exception("Not implemented: isLocalHost");
+}
+
 void SystemInfo::getSystemId (std::string &osName,
                               std::string &nodeName,
                               std::string &release,

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/xml/XmlExchange.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/xml/XmlExchange.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/xml/XmlExchange.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/xml/XmlExchange.cpp Thu Jun 28 09:14:52 2012
@@ -101,7 +101,7 @@ XmlBinding::XmlBinding(const std::string
 }
 
      
-XmlExchange::XmlExchange(const string& _name, Manageable* _parent, Broker* b) : Exchange(_name, _parent, b)
+XmlExchange::XmlExchange(const std::string& _name, Manageable* _parent, Broker* b) : Exchange(_name, _parent, b)
 {
     if (mgmtExchange != 0)
         mgmtExchange->set_type (typeName);
@@ -115,7 +115,7 @@ XmlExchange::XmlExchange(const std::stri
         mgmtExchange->set_type (typeName);
 }
     
-bool XmlExchange::bind(Queue::shared_ptr queue, const string& bindingKey, const FieldTable* args)
+bool XmlExchange::bind(Queue::shared_ptr queue, const std::string& bindingKey, const FieldTable* args)
 { 
 
     // Federation uses bind for unbind and reorigin comands as well as for binds.
@@ -123,9 +123,9 @@ bool XmlExchange::bind(Queue::shared_ptr
     // Both federated and local binds are done in this method.  Other
     // federated requests are done by calling the relevent methods.
 
-    string fedOp;
-    string fedTags;
-    string fedOrigin;
+    std::string fedOp;
+    std::string fedTags;
+    std::string fedOrigin;
     
     if (args) 
         fedOp = args->getAsString(qpidFedOp);
@@ -146,7 +146,7 @@ bool XmlExchange::bind(Queue::shared_ptr
     
     else if (fedOp.empty() || fedOp == fedOpBind) {
 
-        string queryText = args->getAsString("xquery");
+        std::string queryText = args->getAsString("xquery");
 
         RWlock::ScopedWlock l(lock);   
  
@@ -175,7 +175,7 @@ bool XmlExchange::bind(Queue::shared_ptr
     return true;
 }
 
-bool XmlExchange::unbind(Queue::shared_ptr queue, const string& bindingKey, const FieldTable* args)
+bool XmlExchange::unbind(Queue::shared_ptr queue, const std::string& bindingKey, const FieldTable* args)
 {
     /*
      *  When called directly, no qpidFedOrigin argument will be
@@ -184,7 +184,7 @@ bool XmlExchange::unbind(Queue::shared_p
      *  This is a bit of a hack - the binding needs the origin, but
      *  this interface, as originally defined, would not supply one.
      */
-    string fedOrigin;
+    std::string fedOrigin;
     if (args) fedOrigin = args->getAsString(qpidFedOrigin);
 
     RWlock::ScopedWlock l(lock);
@@ -200,7 +200,7 @@ bool XmlExchange::unbind(Queue::shared_p
 
 bool XmlExchange::matches(Query& query, Deliverable& msg, const qpid::framing::FieldTable* args, bool parse_message_content) 
 {
-    string msgContent;
+    std::string msgContent;
 
     try {
         QPID_LOG(trace, "matches: query is [" << UTF8(query->getQueryText()) << "]");
@@ -285,7 +285,7 @@ bool XmlExchange::matches(Query& query, 
 
 void XmlExchange::route(Deliverable& msg)
 {
-    const string& routingKey = msg.getMessage().getRoutingKey();
+    const std::string& routingKey = msg.getMessage().getRoutingKey();
     const FieldTable* args = msg.getMessage().getApplicationHeaders();
     PreRoute pr(msg, this);
     try {
@@ -309,7 +309,7 @@ void XmlExchange::route(Deliverable& msg
 }
 
 
-bool XmlExchange::isBound(Queue::shared_ptr queue, const string* const bindingKey, const FieldTable* const) 
+bool XmlExchange::isBound(Queue::shared_ptr queue, const std::string* const bindingKey, const FieldTable* const) 
 {
     RWlock::ScopedRlock l(lock);
     if (bindingKey) {
@@ -345,7 +345,7 @@ void XmlExchange::propagateFedOp(const s
 
     if (args) {            
         for (qpid::framing::FieldTable::ValueMap::const_iterator i=args->begin(); i != args->end(); ++i)  {
-            const string& name(i->first);
+            const std::string& name(i->first);
             if (name != qpidFedOp &&
                 name != qpidFedTags &&
                 name != qpidFedOrigin)  {
@@ -358,7 +358,7 @@ void XmlExchange::propagateFedOp(const s
     Exchange::propagateFedOp(bindingKey, fedTags, fedOp, fedOrigin, propArgs);
 }
 
-bool XmlExchange::fedUnbind(const string& fedOrigin, const string& fedTags, Queue::shared_ptr queue, const string& bindingKey, const FieldTable* args)
+bool XmlExchange::fedUnbind(const std::string& fedOrigin, const std::string& fedTags, Queue::shared_ptr queue, const std::string& bindingKey, const FieldTable* args)
 {
     RWlock::ScopedRlock l(lock);
 
@@ -376,19 +376,19 @@ void XmlExchange::fedReorigin()
         RWlock::ScopedRlock l(lock);   
         for (XmlBindingsMap::iterator i = bindingsMap.begin(); i != bindingsMap.end(); ++i) {
             XmlBinding::vector::ConstPtr p = i->second.snapshot();
-            if (std::find_if(p->begin(), p->end(), MatchOrigin(string())) != p->end()) {
+            if (std::find_if(p->begin(), p->end(), MatchOrigin(std::string())) != p->end()) {
                 keys2prop.push_back(i->first);
             }
         }
     }   /* lock dropped */
     for (std::vector<std::string>::const_iterator key = keys2prop.begin();
          key != keys2prop.end(); key++) {
-        propagateFedOp( *key, string(), fedOpBind, string());
+        propagateFedOp( *key, std::string(), fedOpBind, std::string());
     }
 }
 
 
-XmlExchange::MatchOrigin::MatchOrigin(const string& _origin) : origin(_origin) {}
+XmlExchange::MatchOrigin::MatchOrigin(const std::string& _origin) : origin(_origin) {}
 
 bool XmlExchange::MatchOrigin::operator()(XmlBinding::shared_ptr b)
 {
@@ -396,7 +396,7 @@ bool XmlExchange::MatchOrigin::operator(
 }
 
 
-XmlExchange::MatchQueueAndOrigin::MatchQueueAndOrigin(Queue::shared_ptr _queue, const string& _origin) : queue(_queue), origin(_origin) {}
+XmlExchange::MatchQueueAndOrigin::MatchQueueAndOrigin(Queue::shared_ptr _queue, const std::string& _origin) : queue(_queue), origin(_origin) {}
 
 bool XmlExchange::MatchQueueAndOrigin::operator()(XmlBinding::shared_ptr b)
 {

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpid/xml/XmlExchange.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpid/xml/XmlExchange.h?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpid/xml/XmlExchange.h (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpid/xml/XmlExchange.h Thu Jun 28 09:14:52 2012
@@ -35,8 +35,6 @@
 #include <vector>
 #include <string>
 
-using namespace std;
-
 namespace qpid {
 namespace broker {
 
@@ -62,7 +60,7 @@ struct XmlBinding : public Exchange::Bin
 
 class XmlExchange : public virtual Exchange {
 
-    typedef std::map<string, XmlBinding::vector> XmlBindingsMap;
+    typedef std::map<std::string, XmlBinding::vector> XmlBindingsMap;
     XmlBindingsMap bindingsMap;
 
     qpid::sys::RWlock lock;

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpidd.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpidd.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpidd.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpidd.cpp Thu Jun 28 09:14:52 2012
@@ -29,6 +29,9 @@
 #include <memory>
 using namespace std;
 
+namespace qpid {
+namespace broker {
+
 auto_ptr<QpiddOptions> options;
 
 // Broker real entry; various system-invoked entrypoints call here.
@@ -87,3 +90,4 @@ int run_broker(int argc, char *argv[], b
     }
     return 1;
 }
+}}

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/qpidd.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/qpidd.h?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/qpidd.h (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/qpidd.h Thu Jun 28 09:14:52 2012
@@ -26,6 +26,9 @@
 
 #include <memory>
 
+namespace qpid {
+namespace broker {
+
 // BootstrapOptions is a minimal subset of options used for a pre-parse
 // of the command line to discover which plugin modules need to be loaded.
 // The pre-parse is necessary because plugin modules may supply their own
@@ -70,4 +73,5 @@ public:
 // Broker real entry; various system-invoked entrypoints call here.
 int run_broker(int argc, char *argv[], bool hidden = false);
 
+}}
 #endif  /*!QPID_H*/

Propchange: qpid/branches/java-config-and-management/qpid/cpp/src/tests/
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/cpp/src/tests:r1300143-1349442,1349444-1349530,1349532-1353860

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/Array.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/Array.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/Array.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/Array.cpp Thu Jun 28 09:14:52 2012
@@ -58,7 +58,7 @@ QPID_AUTO_TEST_CASE(testEncodeDecode)
     BOOST_CHECK_EQUAL(a, b);
 
     std::vector<std::string> data2;
-    b.collect(data2);
+    std::transform(b.begin(), b.end(), std::back_inserter(data2), Array::get<std::string, Array::ValuePtr>);
     //BOOST_CHECK_EQUAL(data, data2);
     BOOST_CHECK(data == data2);
 }
@@ -74,7 +74,7 @@ QPID_AUTO_TEST_CASE(testArrayAssignment)
         BOOST_CHECK_EQUAL(a, b);
     }
     std::vector<std::string> data2;
-    b.collect(data2);
+    std::transform(b.begin(), b.end(), std::back_inserter(data2), Array::get<std::string, Array::ValuePtr>);
     //BOOST_CHECK_EQUAL(data, data2);
     BOOST_CHECK(data == data2);
 }

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/CMakeLists.txt?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/CMakeLists.txt (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/CMakeLists.txt Thu Jun 28 09:14:52 2012
@@ -23,7 +23,11 @@ include (CTest)
 # Make sure that everything get built before the tests
 # Need to create a var with all the necessary top level targets
 
-add_definitions(-DBOOST_TEST_DYN_LINK)
+# If we're linking Boost for DLLs, turn that on for the unit test too.
+if (QPID_LINK_BOOST_DYNAMIC)
+    add_definitions(-DBOOST_TEST_DYN_LINK)
+endif (QPID_LINK_BOOST_DYNAMIC)
+
 include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
 
 include (FindPythonInterp)
@@ -145,19 +149,13 @@ set(unit_tests_to_build
     PollableCondition
     Variant
     ClientMessage
+    SystemInfo
     ${xml_tests}
     CACHE STRING "Which unit tests to build"
    )
 
 mark_as_advanced(unit_tests_to_build)
 
-# Disabled till we move to amqp_0_10 codec.
-# 	amqp_0_10/serialize.cpp allSegmentTypes.h \
-# 	amqp_0_10/ProxyTemplate.cpp \
-# 	amqp_0_10/apply.cpp \
-# 	amqp_0_10/Map.cpp \
-# 	amqp_0_10/handlers.cpp 
-
 add_executable (unit_test unit_test
                 ${unit_tests_to_build} ${platform_test_additions})
 target_link_libraries (unit_test
@@ -326,7 +324,7 @@ if (BUILD_MSSQL)
   add_test (store_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_store_tests${test_script_suffix} MSSQL)
 endif (BUILD_MSSQL)
 if (BUILD_MSCLFS)
-  add_test (store_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_store_tests${test_script_suffix} MSSQL-CLFS)
+  add_test (store_tests_clfs ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_store_tests${test_script_suffix} MSSQL-CLFS)
 endif (BUILD_MSCLFS)
 endif (PYTHON_EXECUTABLE)
 

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/ExchangeTest.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/ExchangeTest.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/ExchangeTest.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/ExchangeTest.cpp Thu Jun 28 09:14:52 2012
@@ -33,6 +33,8 @@
 #include <iostream>
 #include "MessageUtils.h"
 
+using std::string;
+
 using boost::intrusive_ptr;
 using namespace qpid::broker;
 using namespace qpid::framing;

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/FieldTable.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/FieldTable.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/FieldTable.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/FieldTable.cpp Thu Jun 28 09:14:52 2012
@@ -19,16 +19,19 @@
  *
  */
 #include <iostream>
+#include <algorithm>
+#include "qpid/sys/alloca.h"
 #include "qpid/framing/Array.h"
 #include "qpid/framing/FieldTable.h"
 #include "qpid/framing/FieldValue.h"
 #include "qpid/framing/List.h"
-#include "qpid/sys/alloca.h"
 
 #include "unit_test.h"
 
 using namespace qpid::framing;
 
+using std::string;
+
 namespace qpid {
 namespace tests {
 
@@ -73,11 +76,11 @@ QPID_AUTO_TEST_CASE(testAssignment)
         FieldTable c;
         c = a;
 
-        char* buff = static_cast<char*>(::alloca(c.encodedSize()));
-        Buffer wbuffer(buff, c.encodedSize());
+        std::vector<char> buff(c.encodedSize());
+        Buffer wbuffer(&buff[0], c.encodedSize());
         wbuffer.put(c);
 
-        Buffer rbuffer(buff, c.encodedSize());
+        Buffer rbuffer(&buff[0], c.encodedSize());
         rbuffer.get(d);
         BOOST_CHECK_EQUAL(c, d);
         BOOST_CHECK(string("CCCC") == c.getAsString("A"));
@@ -127,7 +130,7 @@ QPID_AUTO_TEST_CASE(testNestedValues)
         BOOST_CHECK(string("B") == b.getAsString("id"));
         a.getArray("C", c);
         std::vector<std::string> items;
-        c.collect(items);
+        std::transform(c.begin(), c.end(), std::back_inserter(items), Array::get<std::string, Array::ValuePtr>);
         BOOST_CHECK((uint) 2 == items.size());
         BOOST_CHECK(string("one") == items[0]);
         BOOST_CHECK(string("two") == items[1]);

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/Frame.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/Frame.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/Frame.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/Frame.cpp Thu Jun 28 09:14:52 2012
@@ -30,7 +30,6 @@ QPID_AUTO_TEST_SUITE(FrameTestSuite)
 
 using namespace std;
 using namespace qpid::framing;
-using namespace boost;
 
 QPID_AUTO_TEST_CASE(testContentBody) {
     Frame f(42, AMQContentBody("foobar"));

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/FramingTest.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/FramingTest.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/FramingTest.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/FramingTest.cpp Thu Jun 28 09:14:52 2012
@@ -25,6 +25,7 @@
 #include "qpid/framing/all_method_bodies.h"
 #include "qpid/framing/amqp_framing.h"
 #include "qpid/framing/reply_exceptions.h"
+#include "qpid/framing/FieldValue.h"
 #include "unit_test.h"
 
 #include <boost/bind.hpp>

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/Makefile.am
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/Makefile.am?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/Makefile.am (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/Makefile.am Thu Jun 28 09:14:52 2012
@@ -67,7 +67,7 @@ tmodule_LTLIBRARIES=
 
 TESTS+=unit_test
 check_PROGRAMS+=unit_test
-unit_test_LDADD=-lboost_unit_test_framework \
+unit_test_LDADD=-lboost_unit_test_framework -lpthread \
 	$(lib_messaging) $(lib_broker) $(lib_console) $(lib_qmf2)
 
 unit_test_SOURCES= unit_test.cpp unit_test.h \
@@ -124,7 +124,8 @@ unit_test_SOURCES= unit_test.cpp unit_te
 	Address.cpp \
 	ClientMessage.cpp \
 	Qmf2.cpp \
-	BrokerOptions.cpp
+	BrokerOptions.cpp \
+	SystemInfo.cpp
 
 if HAVE_XML
 unit_test_SOURCES+= XmlClientSessionTest.cpp
@@ -149,8 +150,8 @@ endif
 
 # Test programs that are installed and therefore built as part of make, not make check
 
-qpidexectest_SCRIPTS += qpid-cpp-benchmark install_env.sh
-EXTRA_DIST += qpid-cpp-benchmark install_env.sh
+qpidexectest_SCRIPTS += qpid-cpp-benchmark qpid-cluster-benchmark install_env.sh
+EXTRA_DIST += qpid-cpp-benchmark qpid-cluster-benchmark install_env.sh
 
 qpidexectest_PROGRAMS += receiver
 receiver_SOURCES = \
@@ -305,7 +306,7 @@ TESTS_ENVIRONMENT = \
 system_tests = qpid-client-test quick_perftest quick_topictest run_header_test quick_txtest \
   run_msg_group_tests
 TESTS += start_broker $(system_tests) python_tests stop_broker \
-  ha_tests.py run_federation_tests run_federation_sys_tests \
+  run_ha_tests run_federation_tests run_federation_sys_tests \
   run_acl_tests run_cli_tests replication_test dynamic_log_level_test \
   run_queue_flow_limit_tests ipv6_test
 
@@ -320,7 +321,7 @@ EXTRA_DIST +=								\
   header_test.py							\
   ssl_test								\
   config.null								\
-  ais_check								\
+  cpg_check.sh.in							\
   run_federation_tests							\
   run_federation_sys_tests                  \
   run_long_federation_sys_tests             \
@@ -352,7 +353,9 @@ EXTRA_DIST +=								\
   run_queue_flow_limit_tests						\
   run_msg_group_tests							\
   ipv6_test								\
-  ha_tests.py
+  run_ha_tests								\
+  ha_tests.py								\
+  test_env.ps1.in
 
 check_LTLIBRARIES += libdlclose_noop.la
 libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir)
@@ -367,9 +370,15 @@ LONG_TESTS+=start_broker \
  fanout_perftest shared_perftest multiq_perftest topic_perftest run_ring_queue_test \
  run_msg_group_tests_soak \
  stop_broker \
- run_long_federation_sys_tests \
- run_failover_soak reliable_replication_test \
- federated_cluster_test_with_node_failure
+ run_long_federation_sys_tests
+
+if HAVE_LIBCPG
+
+LONG_TESTS+=	federated_cluster_test_with_node_failure	\
+		run_failover_soak				\
+		reliable_replication_test
+
+endif HAVE_LIBCPG
 
 EXTRA_DIST+=						\
 	fanout_perftest					\
@@ -380,7 +389,8 @@ EXTRA_DIST+=						\
 	reliable_replication_test			\
 	federated_cluster_test_with_node_failure        \
 	sasl_test_setup.sh                              \
-	run_msg_group_tests_soak
+	run_msg_group_tests_soak			\
+	qpidd-empty.conf
 
 check-long:
 	$(MAKE) check TESTS="$(LONG_TESTS)" VALGRIND=

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageBuilderTest.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageBuilderTest.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageBuilderTest.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageBuilderTest.cpp Thu Jun 28 09:14:52 2012
@@ -40,7 +40,7 @@ class MockMessageStore : public NullMess
 
     uint64_t id;
     boost::intrusive_ptr<PersistableMessage> expectedMsg;
-    string expectedData;
+    std::string expectedData;
     std::list<Op> ops;
 
     void checkExpectation(Op actual)
@@ -58,7 +58,7 @@ class MockMessageStore : public NullMess
         ops.push_back(STAGE);
     }
 
-    void expectAppendContent(PersistableMessage& msg, const string& data)
+    void expectAppendContent(PersistableMessage& msg, const std::string& data)
     {
         expectedMsg = &msg;
         expectedData = data;
@@ -73,7 +73,7 @@ class MockMessageStore : public NullMess
     }
 
     void appendContent(const boost::intrusive_ptr<const PersistableMessage>& msg,
-                       const string& data)
+                       const std::string& data)
     {
         checkExpectation(APPEND);
         BOOST_CHECK_EQUAL(boost::static_pointer_cast<const PersistableMessage>(expectedMsg), msg);

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageTest.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageTest.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageTest.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageTest.cpp Thu Jun 28 09:14:52 2012
@@ -24,7 +24,6 @@
 #include "qpid/framing/MessageTransferBody.h"
 #include "qpid/framing/FieldValue.h"
 #include "qpid/framing/Uuid.h"
-#include "qpid/sys/alloca.h"
 
 #include "unit_test.h"
 
@@ -33,6 +32,8 @@
 using namespace qpid::broker;
 using namespace qpid::framing;
 
+using std::string;
+
 namespace qpid {
 namespace tests {
 
@@ -69,11 +70,11 @@ QPID_AUTO_TEST_CASE(testEncodeDecode)
     dProps->setDeliveryMode(PERSISTENT);
     BOOST_CHECK(msg->isPersistent());
 
-    char* buff = static_cast<char*>(::alloca(msg->encodedSize()));
-    Buffer wbuffer(buff, msg->encodedSize());
+    std::vector<char> buff(msg->encodedSize());
+    Buffer wbuffer(&buff[0], msg->encodedSize());
     msg->encode(wbuffer);
 
-    Buffer rbuffer(buff, msg->encodedSize());
+    Buffer rbuffer(&buff[0], msg->encodedSize());
     msg = new Message();
     msg->decodeHeader(rbuffer);
     msg->decodeContent(rbuffer);

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageUtils.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageUtils.h?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageUtils.h (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessageUtils.h Thu Jun 28 09:14:52 2012
@@ -33,7 +33,7 @@ namespace tests {
 
 struct MessageUtils
 {
-    static boost::intrusive_ptr<Message> createMessage(const string& exchange="", const string& routingKey="",
+    static boost::intrusive_ptr<Message> createMessage(const std::string& exchange="", const std::string& routingKey="",
                                                        const bool durable = false, const Uuid& messageId=Uuid(true),
                                                        uint64_t contentSize = 0)
     {
@@ -53,7 +53,7 @@ struct MessageUtils
         return msg;
     }
 
-    static void addContent(boost::intrusive_ptr<Message> msg, const string& data)
+    static void addContent(boost::intrusive_ptr<Message> msg, const std::string& data)
     {
         AMQFrame content((AMQContentBody(data)));
         msg->getFrames().append(content);

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessagingSessionTests.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessagingSessionTests.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessagingSessionTests.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/MessagingSessionTests.cpp Thu Jun 28 09:14:52 2012
@@ -1139,6 +1139,13 @@ QPID_AUTO_TEST_CASE(testHeadersExchange)
     }
 }
 
+QPID_AUTO_TEST_CASE(testLargeRoutingKey)
+{
+    MessagingFixture fix;
+    std::string address = "amq.direct/" + std::string(300, 'x');//routing/binding key can be at most 225 chars in 0-10
+    BOOST_CHECK_THROW(fix.session.createReceiver(address), qpid::messaging::MessagingException);
+}
+
 QPID_AUTO_TEST_SUITE_END()
 
 }} // namespace qpid::tests

Modified: qpid/branches/java-config-and-management/qpid/cpp/src/tests/QueueFlowLimitTest.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/cpp/src/tests/QueueFlowLimitTest.cpp?rev=1354874&r1=1354873&r2=1354874&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/cpp/src/tests/QueueFlowLimitTest.cpp (original)
+++ qpid/branches/java-config-and-management/qpid/cpp/src/tests/QueueFlowLimitTest.cpp Thu Jun 28 09:14:52 2012
@@ -27,6 +27,7 @@
 #include "qpid/broker/QueueFlowLimit.h"
 #include "qpid/sys/Time.h"
 #include "qpid/framing/reply_exceptions.h"
+#include "qpid/framing/FieldValue.h"
 #include "MessageUtils.h"
 #include "BrokerFixture.h"
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org