select() errors and AnyEvent::Loop

Felipe Gasper felipe at felipegasper.com
Thu Jul 1 18:09:24 CEST 2021



> On Jun 30, 2021, at 11:37 PM, Marc Lehmann <schmorp at schmorp.de> wrote:
> 
>> Currently if that select() gets EBADF the program tight-loops indefinitely.
> 
> I am confused still - are you talking about a specific program that uses
> AnyEvent, or AnyEvent::Loop? The latter certainly does not behave the way
> you describe.

It does tight-loop:

strace perl -MAnyEvent -e'pipe my $r, my $w; my $fd = fileno $r; close $w; my $cv = AE::cv(); close $r; my $w = AE::io( $fd, "r", $cv ); $cv->recv()'

… but that’s only indefinite if there’s no timer. AE::Loop *could* detect situations whether select() fails and there is no timer. <shrug>

FWIW, EV/epoll stops right away with the above … though it also doesn’t report the EBADF.

>> “Best effort” would, I’d think, be to throw in this case so that the problem is more easily identified.
> 
> I don't see how "throwing" would make the problem more easily identified.
> Certainly, "throwing" is unlikely to be correct for _any_ program?

In a “happy-path” scenario, sure, but when errors happen it’s nice IMO to report them rather than discarding them. Yes, it’s the calling program that needs to be fixed, but it’s much easier to do that if the called library helps out.

-F


More information about the anyevent mailing list