diff options
Diffstat (limited to 'cpp/lib/broker/BrokerChannel.cpp')
-rw-r--r-- | cpp/lib/broker/BrokerChannel.cpp | 20 |
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()); } } |