[libanyevent-rabbitmq-perl] 28/151: Local Queue was divided into the method and the content.

Damyan Ivanov dmn at moszumanska.debian.org
Thu Jan 16 11:03:01 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 398cce0df25659aaddf35c66610438649ee81f52
Author: cooldaemon <cooldaemon at gmail.com>
Date:   Wed Feb 24 23:45:53 2010 +0900

    Local Queue was divided into the method and the content.
---
 lib/AnyEvent/RabbitMQ.pm         | 15 +++++++++++----
 lib/AnyEvent/RabbitMQ/Channel.pm | 17 ++++++++++-------
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/lib/AnyEvent/RabbitMQ.pm b/lib/AnyEvent/RabbitMQ.pm
index 18172ad..ede6a25 100644
--- a/lib/AnyEvent/RabbitMQ.pm
+++ b/lib/AnyEvent/RabbitMQ.pm
@@ -93,14 +93,14 @@ sub _read_loop {
 
         if (length($data) <= 7) {
             $failure_cb->('Broken data was received');
-            @_ = ($self, $failure_cb,);
+            @_ = ($self, $close_cb, $failure_cb,);
             goto &_read_loop;
         }
 
         my ($type_id, $channel, $length,) = unpack 'CnN', substr $data, 0, 7, '';
         if (!defined $type_id || !defined $channel || !defined $length) {
             $failure_cb->('Broken data was received');
-            @_ = ($self, $failure_cb,);
+            @_ = ($self, $close_cb, $failure_cb,);
             goto &_read_loop;
         }
 
@@ -130,7 +130,7 @@ sub _read_loop {
                 }
             }
 
-            @_ = ($self, $failure_cb,);
+            @_ = ($self, $close_cb, $failure_cb,);
             goto &_read_loop;
         });
     });
@@ -368,7 +368,14 @@ sub _push_read_and_valid {
     my ($exp, $cb, $failure_cb, $id,) = @_;
     $exp = ref($exp) eq 'ARRAY' ? $exp : [$exp];
 
-    my $queue = $id ? $self->{_channels}->{$id}->queue : $self->{_queue};
+    my $queue;
+    if (!$id) {
+        $queue = $self->{_queue};
+    } elsif (defined $self->{_channels}->{$id}) {
+        $queue = $self->{_channels}->{$id}->queue;
+    } else {
+        $failure_cb->('Unknown channel id: ' . $id);
+    }
 
     $queue->get(sub {
         my $frame = shift;
diff --git a/lib/AnyEvent/RabbitMQ/Channel.pm b/lib/AnyEvent/RabbitMQ/Channel.pm
index dc52f72..fbcb21d 100644
--- a/lib/AnyEvent/RabbitMQ/Channel.pm
+++ b/lib/AnyEvent/RabbitMQ/Channel.pm
@@ -12,10 +12,11 @@ sub new {
     my $class = shift;
     my $self = bless {
         @_, # id, connection, on_close
-        _is_open      => 0,
-        _queue        => AnyEvent::RabbitMQ::LocalQueue->new,
-        _consumer_cbs => {},
-        _return_cbs   => {},
+        _is_open       => 0,
+        _queue         => AnyEvent::RabbitMQ::LocalQueue->new,
+        _content_queue => AnyEvent::RabbitMQ::LocalQueue->new,
+        _consumer_cbs  => {},
+        _return_cbs    => {},
     }, $class;
     weaken($self->{connection});
     return $self;
@@ -535,9 +536,11 @@ sub push_queue_or_consume {
             $self->_push_read_header_and_body('return', $frame, $cb, $failure_cb);
             return $self;
         }
+        $self->{_queue}->push($frame);
+    } else {
+        $self->{_content_queue}->push($frame);
     }
 
-    $self->{_queue}->push($frame);
     return $self;
 }
 
@@ -546,7 +549,7 @@ sub _push_read_header_and_body {
     my ($type, $frame, $cb, $failure_cb,) = @_;
     my $response = {$type => $frame};
 
-    $self->{_queue}->get(sub{
+    $self->{_content_queue}->get(sub{
         my $frame = shift;
 
         return $failure_cb->('Received data is not header frame')
@@ -561,7 +564,7 @@ sub _push_read_header_and_body {
         $response->{header} = $header_frame;
     });
 
-    $self->{_queue}->get(sub{
+    $self->{_content_queue}->get(sub{
         my $frame = shift;
 
         return $failure_cb->('Received data is not body frame')

-- 
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