select() errors and AnyEvent::Loop
Felipe Gasper
felipe at felipegasper.com
Mon Jun 7 18:57:30 CEST 2021
> On Jun 1, 2021, at 2:08 PM, Felipe Gasper <felipe at felipegasper.com> wrote:
>
> Hi all,
>
> I’ve noticed that AnyEvent::Loop doesn’t check for select() failures. Is this by design?
>
> In my testing it leads to a tight loop if, e.g., a file descriptor gets closed from underneath (possible w/ buggy XS modules or misuse of POSIX::close()) or if ENOMEM happens.
Pursuant to this: what if the following were added?
-----
diff --git a/lib/AnyEvent/Loop.pm b/lib/AnyEvent/Loop.pm
index fb9351a..5015e1e 100644
--- a/lib/AnyEvent/Loop.pm
+++ b/lib/AnyEvent/Loop.pm
@@ -254,6 +254,8 @@ sub one_event {
CORE::select undef, undef, undef, $wait if $wait;
} elsif (!@timer || $timer[0][0] > $MNOW && !$fds) {
$$$_ && $$$_->() for @idle = grep $$$_, @idle;
+ } elsif (-1 == $fds) {
+ die "select(): $!";
}
}
}
-----
-FG
More information about the anyevent
mailing list