Skip to content

Commit

Permalink
be a little more defensive regarding closed handles
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 14, 2017
1 parent 38a7cad commit f7554d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/Reactor/Poll.pm
Expand Up @@ -14,7 +14,7 @@ sub again {

sub io {
my ($self, $handle, $cb) = @_;
$self->{io}{fileno $handle} = {cb => $cb};
$self->{io}{fileno($handle) // croak 'Handle is closed'} = {cb => $cb};
return $self->watch($handle, 1, 1);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ sub recurring { shift->_timer(1, @_) }
sub remove {
my ($self, $remove) = @_;
return !!delete $self->{timers}{$remove} unless ref $remove;
return !!delete $self->{io}{fileno $remove};
return !!delete $self->{io}{fileno($remove) // croak 'Handle is closed'};
}

sub reset { delete @{shift()}{qw(events io next_tick next_timer timers)} }
Expand Down

0 comments on commit f7554d7

Please sign in to comment.