summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2009-05-04 21:29:41 +0000
committerAlan Conway <aconway@apache.org>2009-05-04 21:29:41 +0000
commitc3f3974777da51cc762fc42da96c9cdce66a2280 (patch)
tree606559d6e374f1a73931d3117c62e9d53e3d141e
parent7536c5e15901106f0e33a949e9945713a4b5a1ff (diff)
downloadqpid-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
-rw-r--r--qpid/cpp/src/qpid/client/ConnectionImpl.cpp5
-rw-r--r--qpid/cpp/src/qpid/client/ConnectionImpl.h6
-rw-r--r--qpid/python/qpid/connection.py3
3 files changed, 9 insertions, 5 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);
diff --git a/qpid/python/qpid/connection.py b/qpid/python/qpid/connection.py
index 3ab430587a..d4c5755219 100644
--- a/qpid/python/qpid/connection.py
+++ b/qpid/python/qpid/connection.py
@@ -123,8 +123,7 @@ class Connection(Assembler):
self.lock.release()
def __channel(self):
- # XXX: ch 0?
- for i in xrange(self.channel_max):
+ for i in xrange(1, self.channel_max):
if not self.attached.has_key(i):
return i
else: