If using kevent(2) in the event loop, kevent actually accepts
EVFILT_READ for regular files instead of triggering EPERM
as epoll_ctl(2) does. This kevent-specific behavior doesn't
work with our expected use with static files which don't see
modifications.
I noticed this on FreeBSD when trying to make lei use kevent
for everything instead of select(2) for sockets and
kevent for EVFILT_SIGNAL only.
sub consume {
my ($in, $cb, @args) = @_;
my $self = bless { cb => $cb, args => \@args }, __PACKAGE__;
- eval { $self->SUPER::new($in, EPOLLIN) };
- if ($@) { # regular file (but not w/ select|IO::Poll backends)
+ if (-p $in || -S _) {
+ $in->blocking(0);
+ $self->SUPER::new($in, EPOLLIN);
+ } else { # regular file (but not w/ select|IO::Poll backends)
+ $self->{sock} = $in;
$self->{-need_rq} = 1;
$self->requeue;
- } elsif (-p $in || -S _) { # O_NONBLOCK for sockets and pipes
- $in->blocking(0);
}
$self;
}