[libanyevent-rabbitmq-perl] 99/151: Fix the ->new_channel ->close race
Damyan Ivanov
dmn at moszumanska.debian.org
Thu Jan 16 11:03:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
dmn pushed a commit to annotated tag debian/1.12-1
in repository libanyevent-rabbitmq-perl.
commit a14951f58a607e310ea48f3933a7f78fd9717bf0
Author: Tomas Doran <bobtfish at bobtfish.net>
Date: Thu Jan 5 12:14:14 2012 +0000
Fix the ->new_channel ->close race
---
Changes | 7 +++++++
lib/AnyEvent/RabbitMQ/Channel.pm | 15 +++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/Changes b/Changes
index 2449377..e4325f9 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,12 @@
Revision history for Perl extension AnyEvent::RabbitMQ
+ - Fix a race condition stopping connections from closing properly.
+ If you ask to open a channel, and then immediately try to close
+ the connection then the not yet open channel would never remove
+ itself from the associated connection, resulting in the connection
+ never being terminated (as there were still channels associated with
+ it).
+
- Stop leaking all RabbitMQ messages recieved back inside
a closure.
diff --git a/lib/AnyEvent/RabbitMQ/Channel.pm b/lib/AnyEvent/RabbitMQ/Channel.pm
index 2d20666..95419ab 100644
--- a/lib/AnyEvent/RabbitMQ/Channel.pm
+++ b/lib/AnyEvent/RabbitMQ/Channel.pm
@@ -42,7 +42,9 @@ sub open {
$self->{_is_active} = 1;
$args{on_success}->();
},
- $args{on_failure},
+ sub {
+ $args{on_failure}->(@_);
+ },
$self->{id},
);
@@ -55,7 +57,16 @@ sub close {
or return;
my %args = $connection->_set_cbs(@_);
- return $self if !$self->{_is_open};
+ # Ensure to remove this channel from the connection even if we're not
+ # fully open to ensure $rf->close works always.
+ # FIXME - We can end up racing here so the server thinks the channel is
+ # open, but we've closed it - a more elegant fix would be to mark that
+ # the channel is opening, and wait for it to open before closing it
+ if (!$self->{_is_open}) {
+ $self->{connection}->delete_channel($self->{id});
+ $args{on_success}->($self);
+ return $self;
+ }
return $self->_close(%args) if 0 == scalar keys %{$self->{_consumer_cbs}};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libanyevent-rabbitmq-perl.git
More information about the Pkg-perl-cvs-commits
mailing list