From 3c20c531712c067b040320d2fc48af915c8de112 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 4 May 2009 21:29:41 +0000 Subject: 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/qpid@771452 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/ConnectionImpl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp') diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index b1e83025ab..6639f92324 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -32,6 +32,7 @@ #include #include +#include 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::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& session, uint16_t channel) { Mutex::ScopedLock l(lock); - session->setChannel(channel ? channel : nextChannel++); + session->setChannel(channel == NEXT_CHANNEL ? nextChannel++ : channel); boost::weak_ptr& s = sessions[session->getChannel()]; boost::shared_ptr ss = s.lock(); if (ss) throw SessionBusyException(QPID_MSG("Channel " << ss->getChannel() << " attached to " << ss->getId())); -- cgit v1.2.1