Skip to content

Commit

Permalink
mention reactor in sandbox error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 29, 2013
1 parent a7a0779 commit 649ac29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/Mojo/Reactor/EV.pm
Expand Up @@ -49,8 +49,8 @@ sub watch {
sub _io {
my ($self, $fd, $w, $revents) = @_;
my $io = $self->{io}{$fd};
$self->_sandbox('Read', $io->{cb}, 0) if EV::READ &$revents;
$self->_sandbox('Write', $io->{cb}, 1)
$self->_sandbox('read', $io->{cb}, 0) if EV::READ &$revents;
$self->_sandbox('write', $io->{cb}, 1)
if EV::WRITE &$revents && $self->{io}{$fd};
}

Expand All @@ -62,7 +62,7 @@ sub _timer {
weaken $self;
$self->{timers}{$id}{watcher} = EV::timer(
$after => $after => sub {
$self->_sandbox("Timer $id", $self->{timers}{$id}{cb});
$self->_sandbox("timer $id", $self->{timers}{$id}{cb});
delete $self->{timers}{$id} unless $recurring;
}
);
Expand Down
11 changes: 6 additions & 5 deletions lib/Mojo/Reactor/Poll.pm
Expand Up @@ -42,9 +42,9 @@ sub one_tick {
# I/O
if (keys %{$self->{io}}) {
$poll->poll($timeout);
++$i and $self->_sandbox('Read', $self->{io}{fileno $_}{cb}, 0)
++$i and $self->_sandbox('read', $self->{io}{fileno $_}{cb}, 0)
for $poll->handles(POLLIN | POLLHUP | POLLERR);
++$i and $self->_sandbox('Write', $self->{io}{fileno $_}{cb}, 1)
++$i and $self->_sandbox('write', $self->{io}{fileno $_}{cb}, 1)
for $poll->handles(POLLOUT);
}

Expand All @@ -63,7 +63,7 @@ sub one_tick {
# Normal timer
else { $self->remove($id) }

++$i and $self->_sandbox("Timer $id", $t->{cb}) if $t->{cb};
++$i and $self->_sandbox("timer $id", $t->{cb}) if $t->{cb};
}
}

Expand Down Expand Up @@ -105,8 +105,9 @@ sub watch {
sub _poll { shift->{poll} ||= IO::Poll->new }

sub _sandbox {
my ($self, $desc, $cb) = (shift, shift, shift);
eval { $self->$cb(@_); 1 } or $self->emit(error => "$desc failed: $@");
my ($self, $event, $cb) = (shift, shift, shift);
$self->emit(error => "Reactor $event failed: $@")
unless eval { $self->$cb(@_); 1 };
}

sub _timer {
Expand Down

0 comments on commit 649ac29

Please sign in to comment.