diff options
author | Alan Conway <aconway@apache.org> | 2009-05-04 21:29:41 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2009-05-04 21:29:41 +0000 |
commit | c3f3974777da51cc762fc42da96c9cdce66a2280 (patch) | |
tree | 606559d6e374f1a73931d3117c62e9d53e3d141e /qpid/cpp | |
parent | 7536c5e15901106f0e33a949e9945713a4b5a1ff (diff) | |
download | qpid-python-c3f3974777da51cc762fc42da96c9cdce66a2280.tar.gz |
Fix issue with python clients to cluster, mis handling of channel 0.
cpp/src/qpid/client/ConnectionImpl.cpp: allow 0 as a valid channel identifier.
python/qpid/connection.py: don't use 0 as a channel identifier.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@771452 13f79535-47bb-0310-9956-ffa450edef68
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); |