Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix forking while iterating over file handles with events, specifical…
…ly using $_
  • Loading branch information
jberger committed Jul 6, 2014
1 parent d252277 commit d9aaa88
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/Mojo/Reactor/Poll.pm
Expand Up @@ -42,10 +42,14 @@ sub one_tick {
# I/O
if (keys %{$self->{io}}) {
$poll->poll($timeout);
++$i and $self->_sandbox('Read', $self->{io}{fileno $_}{cb}, 0)
for $poll->handles(POLLIN | POLLPRI | POLLHUP | POLLERR);
++$i and $self->_sandbox('Write', $self->{io}{fileno $_}{cb}, 1)
for $poll->handles(POLLOUT);
for my $f ($poll->handles(POLLIN | POLLPRI | POLLHUP | POLLERR)) {
next unless exists $self->{io}{fileno $f};
++$i and $self->_sandbox('Read', $self->{io}{fileno $f}{cb}, 0);
}
for my $f ($poll->handles(POLLOUT)) {
next unless exists $self->{io}{fileno $f};
++$i and $self->_sandbox('Write', $self->{io}{fileno $f}{cb}, 1);
}
}

# Wait for timeout if poll can't be used
Expand Down

0 comments on commit d9aaa88

Please sign in to comment.