You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2007/02/09 17:46:17 UTC
svn commit: r505360 - in /incubator/qpid/branches/qpid.0-9/cpp:
lib/broker/BrokerChannel.cpp lib/broker/BrokerChannel.h
lib/broker/Connection.cpp lib/broker/Connection.h tests/ChannelTest.cpp
Author: gsim
Date: Fri Feb 9 08:46:16 2007
New Revision: 505360
URL: http://svn.apache.org/viewvc?view=rev&rev=505360
Log:
Handle invalid channels.
Modified:
incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.cpp
incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.h
incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.cpp
incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.h
incubator/qpid/branches/qpid.0-9/cpp/tests/ChannelTest.cpp
Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.cpp?view=diff&rev=505360&r1=505359&r2=505360
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.cpp Fri Feb 9 08:46:16 2007
@@ -60,7 +60,7 @@
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 @@
)
{
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());
}
}
Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.h?view=diff&rev=505360&r1=505359&r2=505360
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/broker/BrokerChannel.h Fri Feb 9 08:46:16 2007
@@ -36,6 +36,7 @@
#include <Prefetch.h>
#include <TxBuffer.h>
#include "framing/ChannelAdapter.h"
+#include "ChannelOpenBody.h"
#include "CompletionHandler.h"
namespace qpid {
Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.cpp?view=diff&rev=505360&r1=505359&r2=505360
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.cpp Fri Feb 9 08:46:16 2007
@@ -63,6 +63,11 @@
getChannel(frame->getChannel()).handleBody(frame->getBody());
}
+void Connection::close(ReplyCode code, const string& text, ClassId classId, MethodId methodId){
+ client->getConnection().close(MethodContext(&getChannel(0)), code, text, classId, methodId);
+ getOutput().close();
+}
+
// TODO aconway 2007-02-02: Should be delegated to the BrokerAdapter
// as it is part of the protocol.
void Connection::initiated(qpid::framing::ProtocolInitiation* header) {
Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.h?view=diff&rev=505360&r1=505359&r2=505360
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/broker/Connection.h Fri Feb 9 08:46:16 2007
@@ -86,6 +86,7 @@
Channel& newChannel(framing::ChannelId channel);
Channel& getChannel(framing::ChannelId channel);
void closeChannel(framing::ChannelId channel);
+ void close(framing::ReplyCode code, const string& text, framing::ClassId classId, framing::MethodId methodId);
private:
typedef boost::ptr_map<framing::ChannelId, Channel> ChannelMap;
Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/ChannelTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/ChannelTest.cpp?view=diff&rev=505360&r1=505359&r2=505360
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/ChannelTest.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/ChannelTest.cpp Fri Feb 9 08:46:16 2007
@@ -178,6 +178,7 @@
void testDeliveryNoAck(){
Channel channel(connection, 7, 10000);
+ channel.open();
const string data("abcdefghijklmn");
Message::shared_ptr msg(
createMessage("test", "my_routing_key", "my_message_id", 14));
@@ -207,6 +208,7 @@
void testDeliveryAndRecovery(){
Channel channel(connection, 7, 10000);
+ channel.open();
const string data("abcdefghijklmn");
Message::shared_ptr msg(createMessage("test", "my_routing_key", "my_message_id", 14));