diff options
Diffstat (limited to 'qpid/cpp')
-rw-r--r-- | qpid/cpp/src/qpid/client/ConnectionImpl.cpp | 5 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/client/ConnectionImpl.h | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/qpid/cpp/src/qpid/client/ConnectionImpl.cpp b/qpid/cpp/src/qpid/client/ConnectionImpl.cpp index b1e83025ab..6639f92324 100644 --- a/qpid/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/qpid/cpp/src/qpid/client/ConnectionImpl.cpp @@ -32,6 +32,7 @@ #include <boost/bind.hpp> #include <boost/format.hpp> +#include <limits> namespace qpid { namespace client { @@ -81,6 +82,8 @@ ConnectionImpl::ConnectionImpl(framing::ProtocolVersion v, const ConnectionSetti handler.onError = boost::bind(&ConnectionImpl::closed, this, _1, _2); } +const uint16_t ConnectionImpl::NEXT_CHANNEL = std::numeric_limits<uint16_t>::max(); + ConnectionImpl::~ConnectionImpl() { // Important to close the connector first, to ensure the // connector thread does not call on us while the destructor @@ -92,7 +95,7 @@ ConnectionImpl::~ConnectionImpl() { void ConnectionImpl::addSession(const boost::shared_ptr<SessionImpl>& session, uint16_t channel) { Mutex::ScopedLock l(lock); - session->setChannel(channel ? channel : nextChannel++); + session->setChannel(channel == NEXT_CHANNEL ? nextChannel++ : channel); boost::weak_ptr<SessionImpl>& s = sessions[session->getChannel()]; boost::shared_ptr<SessionImpl> ss = s.lock(); if (ss) throw SessionBusyException(QPID_MSG("Channel " << ss->getChannel() << " attached to " << ss->getId())); diff --git a/qpid/cpp/src/qpid/client/ConnectionImpl.h b/qpid/cpp/src/qpid/client/ConnectionImpl.h index 9385687238..431831b8a1 100644 --- a/qpid/cpp/src/qpid/client/ConnectionImpl.h +++ b/qpid/cpp/src/qpid/client/ConnectionImpl.h @@ -53,6 +53,8 @@ class ConnectionImpl : public Bounds, { typedef std::map<uint16_t, boost::weak_ptr<SessionImpl> > SessionMap; + static const uint16_t NEXT_CHANNEL; + SessionMap sessions; ConnectionHandler handler; boost::scoped_ptr<Connector> connector; @@ -80,8 +82,8 @@ class ConnectionImpl : public Bounds, void open(); bool isOpen() const; - boost::shared_ptr<SessionImpl> newSession(const std::string& name, uint32_t timeout, uint16_t channel=0); - void addSession(const boost::shared_ptr<SessionImpl>&, uint16_t channel=0); + boost::shared_ptr<SessionImpl> newSession(const std::string& name, uint32_t timeout, uint16_t channel=NEXT_CHANNEL); + void addSession(const boost::shared_ptr<SessionImpl>&, uint16_t channel=NEXT_CHANNEL); void close(); void handle(framing::AMQFrame& frame); |