Skip to content

Commit

Permalink
Prevent warning about undefined object on closed channels
Browse files Browse the repository at this point in the history
This prevents warnings like

```
(in cleanup) Can't call method "_handle" on an undefined value at /usr/lib/perl5/vendor_perl/5.18.2/Mojo/RabbitMQ/Client.pm line 354.
```

as reported in #30
  • Loading branch information
okurz committed Aug 9, 2019
1 parent 3556f9a commit d7cfa01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/RabbitMQ/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ sub _connect {

# Connection established
$stream->on(timeout => sub { $self->_error($id, 'Inactivity timeout') });
$stream->on(close => sub { $self->_handle($id, 1) });
$stream->on(close => sub { $self && $self->_handle($id, 1) });
$stream->on(error => sub { $self && $self->_error($id, pop) });
$stream->on(read => sub { $self->_read($id, pop) });
$stream->on(read => sub { $self && $self->_read($id, pop) });
$cb->();
}
);
Expand Down

0 comments on commit d7cfa01

Please sign in to comment.