summaryrefslogtreecommitdiff
path: root/cpp/lib/broker/BrokerChannel.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-02-09 16:46:16 +0000
committerGordon Sim <gsim@apache.org>2007-02-09 16:46:16 +0000
commite754770e56a9ff0df5d5be73b04ed658cdbc5855 (patch)
tree121acfabebc179ce6448b98e4c83b7dbfcb54940 /cpp/lib/broker/BrokerChannel.cpp
parent0b3933e6315389c5d32fb7abea5556c15440f888 (diff)
downloadqpid-python-e754770e56a9ff0df5d5be73b04ed658cdbc5855.tar.gz
Handle invalid channels.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@505360 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/broker/BrokerChannel.cpp')
-rw-r--r--cpp/lib/broker/BrokerChannel.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/cpp/lib/broker/BrokerChannel.cpp b/cpp/lib/broker/BrokerChannel.cpp
index 0d867d0cf3..07636216a6 100644
--- a/cpp/lib/broker/BrokerChannel.cpp
+++ b/cpp/lib/broker/BrokerChannel.cpp
@@ -60,7 +60,7 @@ Channel::Channel(
tagGenerator("sgen"),
store(_store),
messageBuilder(this, _store, _stagingThreshold),
- opened(true),
+ opened(id == 0),//channel 0 is automatically open, other must be explicitly opened
adapter(new BrokerAdapter(*this, con, con.broker))
{
outstanding.reset();
@@ -320,22 +320,22 @@ void Channel::handleMethodInContext(
)
{
try{
- method->invoke(*adapter, context);
+ if(id != 0 && !method->isA<ChannelOpenBody>() && !isOpen()) {
+ std::stringstream out;
+ out << "Attempt to use unopened channel: " << id;
+ throw ConnectionException(504, out.str());
+ } else {
+ method->invoke(*adapter, context);
+ }
}catch(ChannelException& e){
connection.client->getChannel().close(
context, e.code, e.toString(),
method->amqpClassId(), method->amqpMethodId());
connection.closeChannel(getId());
}catch(ConnectionException& e){
- connection.client->getConnection().close(
- context, e.code, e.toString(),
- method->amqpClassId(), method->amqpMethodId());
- connection.getOutput().close();
+ connection.close(e.code, e.toString(), method->amqpClassId(), method->amqpMethodId());
}catch(std::exception& e){
- connection.client->getConnection().close(
- context, 541/*internal error*/, e.what(),
- method->amqpClassId(), method->amqpMethodId());
- connection.getOutput().close();
+ connection.close(541/*internal error*/, e.what(), method->amqpClassId(), method->amqpMethodId());
}
}