Subject: | Closing a channel with multiple consuming queues causes an error |
Hiya
If I am consuming multiple queues with one channel, and I try to close
that channel, it tries to cancel the queues first, but each on_success
callback then tries to close the channel -> error.
here's a patch:
--- AnyEvent/RabbitMQ/Channel.pm 2011-07-11 20:52:21.886343198 +0200
+++ AnyEvent/RabbitMQ/Channel.pm.new 2011-07-11 20:52:15.079059124 +0200
@@ -59,16 +59,19 @@
return $self if !$self->{_is_open};
- return $self->_close(%args) if 0 == scalar keys
%{$self->{_consumer_cbs}};
+ my %cbs = %{$self->{_consumer_cbs}};
+ return $self->_close(%args) unless %cbs;
- for my $consumer_tag (keys %{$self->{_consumer_cbs}}) {
+ for my $consumer_tag (keys %cbs) {
$self->cancel(
consumer_tag => $consumer_tag,
on_success => sub {
- $self->_close(%args);
+ delete $cbs{$consumer_tag};
+ $self->_close(%args) unless %cbs;
},
on_failure => sub {
- $self->_close(%args);
+ delete $cbs{$consumer_tag};
+ $self->_close(%args) unless %cbs;
$args{on_failure}->(@_);
}
);