summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/client/ClientChannel.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-04-05 19:16:09 +0000
committerAlan Conway <aconway@apache.org>2007-04-05 19:16:09 +0000
commit6b5c686b366846b7ecb0bb298c41fe474e1fb3c8 (patch)
tree33e57b5f764c5d9549b150a43df62da193f735eb /qpid/cpp/src/client/ClientChannel.cpp
parent0370e5550e1d9bc72d742bbbee1f6f0e2835406e (diff)
downloadqpid-python-6b5c686b366846b7ecb0bb298c41fe474e1fb3c8.tar.gz
* Exteneded use of shared pointers frame bodies across all send() commands.
* tests/Makefile.am: added check-unit target to run just unit tests. * Introduced make_shared_ptr convenience function for wrapping plain pointers with shared_ptr. * cpp/src/client/ClientChannel.h,cpp (sendsendAndReceive,sendAndReceiveSync): Pass shared_ptr instead of raw ptr to fix memory problems. Updated the following files to use make_shared_ptr - src/client/BasicMessageChannel.cpp - src/client/ClientConnection.cpp * src/client/MessageMessageChannel.cpp: implemented 0-9 message.get. * src/framing/Correlator.h,cpp: Allow request sender to register actions to take when the correlated response arrives. * cpp/src/tests/FramingTest.cpp: Added Correlator tests. * src/framing/ChannelAdapter.h,cpp: use Correlator to dispatch response actions. * cpp/src/shared_ptr.h (make_shared_ptr): Convenience function to make a shared pointer from a raw pointer. * cpp/src/tests/ClientChannelTest.cpp: Added message.get test. * cpp/src/tests/Makefile.am (check-unit): Added test-unit target to run unit tests. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@525932 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/client/ClientChannel.cpp')
-rw-r--r--qpid/cpp/src/client/ClientChannel.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/qpid/cpp/src/client/ClientChannel.cpp b/qpid/cpp/src/client/ClientChannel.cpp
index 99eece46bc..533b590010 100644
--- a/qpid/cpp/src/client/ClientChannel.cpp
+++ b/qpid/cpp/src/client/ClientChannel.cpp
@@ -60,7 +60,7 @@ void Channel::open(ChannelId id, Connection& con)
init(id, con, con.getVersion()); // ChannelAdapter initialization.
string oob;
if (id != 0)
- sendAndReceive<ChannelOpenOkBody>(new ChannelOpenBody(version, oob));
+ sendAndReceive<ChannelOpenOkBody>(make_shared_ptr(new ChannelOpenBody(version, oob)));
}
void Channel::protocolInit(
@@ -77,10 +77,10 @@ void Channel::protocolInit(
string locale("en_US");
ConnectionTuneBody::shared_ptr proposal =
sendAndReceive<ConnectionTuneBody>(
- new ConnectionStartOkBody(
+ make_shared_ptr(new ConnectionStartOkBody(
version, connectionStart->getRequestId(),
props, mechanism,
- response, locale));
+ response, locale)));
/**
* Assume for now that further challenges will not be required
@@ -136,15 +136,15 @@ void Channel::declareExchange(Exchange& exchange, bool synch){
FieldTable args;
sendAndReceiveSync<ExchangeDeclareOkBody>(
synch,
- new ExchangeDeclareBody(
- version, 0, name, type, false, false, false, false, !synch, args));
+ make_shared_ptr(new ExchangeDeclareBody(
+ version, 0, name, type, false, false, false, false, !synch, args)));
}
void Channel::deleteExchange(Exchange& exchange, bool synch){
string name = exchange.getName();
sendAndReceiveSync<ExchangeDeleteOkBody>(
synch,
- new ExchangeDeleteBody(version, 0, name, false, !synch));
+ make_shared_ptr(new ExchangeDeleteBody(version, 0, name, false, !synch)));
}
void Channel::declareQueue(Queue& queue, bool synch){
@@ -153,9 +153,9 @@ void Channel::declareQueue(Queue& queue, bool synch){
QueueDeclareOkBody::shared_ptr response =
sendAndReceiveSync<QueueDeclareOkBody>(
synch,
- new QueueDeclareBody(
+ make_shared_ptr(new QueueDeclareBody(
version, 0, name, false/*passive*/, queue.isDurable(),
- queue.isExclusive(), queue.isAutoDelete(), !synch, args));
+ queue.isExclusive(), queue.isAutoDelete(), !synch, args)));
if(synch) {
if(queue.getName().length() == 0)
queue.setName(response->getQueue());
@@ -167,7 +167,7 @@ void Channel::deleteQueue(Queue& queue, bool ifunused, bool ifempty, bool synch)
string name = queue.getName();
sendAndReceiveSync<QueueDeleteOkBody>(
synch,
- new QueueDeleteBody(version, 0, name, ifunused, ifempty, !synch));
+ make_shared_ptr(new QueueDeleteBody(version, 0, name, ifunused, ifempty, !synch)));
}
void Channel::bind(const Exchange& exchange, const Queue& queue, const std::string& key, const FieldTable& args, bool synch){
@@ -175,15 +175,15 @@ void Channel::bind(const Exchange& exchange, const Queue& queue, const std::stri
string q = queue.getName();
sendAndReceiveSync<QueueBindOkBody>(
synch,
- new QueueBindBody(version, 0, q, e, key,!synch, args));
+ make_shared_ptr(new QueueBindBody(version, 0, q, e, key,!synch, args)));
}
void Channel::commit(){
- sendAndReceive<TxCommitOkBody>(new TxCommitBody(version));
+ sendAndReceive<TxCommitOkBody>(make_shared_ptr(new TxCommitBody(version)));
}
void Channel::rollback(){
- sendAndReceive<TxRollbackOkBody>(new TxRollbackBody(version));
+ sendAndReceive<TxRollbackOkBody>(make_shared_ptr(new TxRollbackBody(version)));
}
void Channel::handleMethodInContext(
@@ -203,7 +203,8 @@ void Channel::handleMethodInContext(
}
try {
switch (method->amqpClassId()) {
- case BasicDeliverBody::CLASS_ID: messaging->handle(method); break;
+ case MessageOkBody::CLASS_ID:
+ case BasicGetOkBody::CLASS_ID: messaging->handle(method); break;
case ChannelCloseBody::CLASS_ID: handleChannel(method); break;
case ConnectionCloseBody::CLASS_ID: handleConnection(method); break;
default: throw UnknownMethod();
@@ -261,8 +262,8 @@ void Channel::close(
try {
if (getId() != 0) {
sendAndReceive<ChannelCloseOkBody>(
- new ChannelCloseBody(
- version, code, text, classId, methodId));
+ make_shared_ptr(new ChannelCloseBody(
+ version, code, text, classId, methodId)));
}
static_cast<ConnectionForChannel*>(connection)->erase(getId());
closeInternal();
@@ -292,7 +293,7 @@ void Channel::closeInternal() {
}
AMQMethodBody::shared_ptr Channel::sendAndReceive(
- AMQMethodBody* toSend, ClassId c, MethodId m)
+ AMQMethodBody::shared_ptr toSend, ClassId c, MethodId m)
{
responses.expect();
send(toSend);
@@ -300,7 +301,7 @@ AMQMethodBody::shared_ptr Channel::sendAndReceive(
}
AMQMethodBody::shared_ptr Channel::sendAndReceiveSync(
- bool sync, AMQMethodBody* body, ClassId c, MethodId m)
+ bool sync, AMQMethodBody::shared_ptr body, ClassId c, MethodId m)
{
if(sync)
return sendAndReceive(body, c, m);