diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/client/Connection.cpp | 5 | ||||
-rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.cpp | 16 | ||||
-rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.h | 4 |
3 files changed, 14 insertions, 11 deletions
diff --git a/cpp/src/qpid/client/Connection.cpp b/cpp/src/qpid/client/Connection.cpp index 32a01b2c40..d8ffb6d9e1 100644 --- a/cpp/src/qpid/client/Connection.cpp +++ b/cpp/src/qpid/client/Connection.cpp @@ -45,7 +45,10 @@ using namespace qpid::sys; namespace qpid { namespace client { -Connection::Connection() : version(framing::highestProtocolVersion) {} +Connection::Connection() : version(framing::highestProtocolVersion) +{ + ConnectionImpl::init(); +} Connection::~Connection() {} diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index 05a781c2d9..b6043518e8 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -137,15 +137,6 @@ IOThread& theIO() { return io; } -// Bring theIO into existence on library load rather than first use. -// This avoids it being destroyed whilst something in the main program -// still exists -struct InitAtLoad { - InitAtLoad() { - (void) theIO(); - } -} init; - class HeartbeatTask : public TimerTask { TimeoutHandler& timeout; @@ -164,6 +155,13 @@ public: } +// Ensure the IO threads exist: +// This needs to be called in the Connection constructor +// so that they will still exist at last connection destruction +void ConnectionImpl::init() { + (void) theIO(); +} + ConnectionImpl::ConnectionImpl(framing::ProtocolVersion v, const ConnectionSettings& settings) : Bounds(settings.maxFrameSize * settings.bounds), handler(settings, v), diff --git a/cpp/src/qpid/client/ConnectionImpl.h b/cpp/src/qpid/client/ConnectionImpl.h index 2b32e1ccf0..1d88fcaf99 100644 --- a/cpp/src/qpid/client/ConnectionImpl.h +++ b/cpp/src/qpid/client/ConnectionImpl.h @@ -50,6 +50,7 @@ class ConnectionImpl : public Bounds, public boost::enable_shared_from_this<ConnectionImpl> { + friend class Connection; typedef std::map<uint16_t, boost::weak_ptr<SessionImpl> > SessionMap; static const uint16_t NEXT_CHANNEL; @@ -65,7 +66,8 @@ class ConnectionImpl : public Bounds, template <class F> void closeInternal(const F&); - void incoming(framing::AMQFrame& frame); + static void init(); + void incoming(framing::AMQFrame& frame); void closed(uint16_t, const std::string&); void idleOut(); void idleIn(); |