From 924764a6a8dbcb0a2dd7a432221987302b389af8 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 22 Sep 2006 09:53:47 +0000 Subject: Added tests for basic_cancel and for handling of invalid channel ids. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@448881 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/broker/src/Channel.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'qpid/cpp/broker/src/Channel.cpp') diff --git a/qpid/cpp/broker/src/Channel.cpp b/qpid/cpp/broker/src/Channel.cpp index 6980fe5a1b..f1f7d63a39 100644 --- a/qpid/cpp/broker/src/Channel.cpp +++ b/qpid/cpp/broker/src/Channel.cpp @@ -57,11 +57,14 @@ void Channel::consume(string& tag, Queue::shared_ptr queue, bool acks, bool excl } void Channel::cancel(string& tag){ - ConsumerImpl* c = consumers[tag]; - if(c){ - c->cancel(); - consumers.erase(tag); - delete c; + consumer_iterator i = consumers.find(tag); + if(i != consumers.end()){ + ConsumerImpl* c = i->second; + consumers.erase(i); + if(c){ + c->cancel(); + delete c; + } } } @@ -69,9 +72,11 @@ void Channel::close(){ //cancel all consumers for(consumer_iterator i = consumers.begin(); i != consumers.end(); i = consumers.begin() ){ ConsumerImpl* c = i->second; - c->cancel(); consumers.erase(i); - delete c; + if(c){ + c->cancel(); + delete c; + } } } -- cgit v1.2.1