Make the connection references weak references.

This commit is contained in:
Bruno Tavares
2014-09-03 18:22:22 +01:00
parent 73801c8488
commit 78c4ca959f

View File

@@ -7,6 +7,7 @@ package AnyEvent::NSQ::Reader;
use strict; use strict;
use warnings; use warnings;
use Carp 'croak'; use Carp 'croak';
use Scalar::Util qw( weaken );
use parent 'AnyEvent::NSQ::Client'; use parent 'AnyEvent::NSQ::Client';
@@ -58,6 +59,7 @@ sub _identified {
## Keep the connection in the registry in case the user ## Keep the connection in the registry in case the user
## wants to issue FIN/REQs inside the callback ## wants to issue FIN/REQs inside the callback
$self->{routing}->{$msg->{message_id}} = $conn; $self->{routing}->{$msg->{message_id}} = $conn;
weaken( $self->{routing}->{$msg->{message_id}} );
my $action = $self->{message_cb}->($self, $msg); my $action = $self->{message_cb}->($self, $msg);