Skip Menu |

This queue is for tickets about the IO-Async-Loop-Epoll CPAN distribution.

Report information
The Basics
Id: 132537
Status: open
Priority: 0/
Queue: IO-Async-Loop-Epoll

People
Owner: Nobody in particular
Requestors: felipe [...] felipegasper.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: EBADF when removing a handle whose FD is closed
Date: Sun, 10 May 2020 08:25:53 -0400
To: bug-IO-Async-Loop-Epoll [...] rt.cpan.org
From: Felipe Gasper <felipe [...] felipegasper.com>
Hello, The script below will fail if the Epoll class is installed because the underlying epoll_ctl gives EBADF for the already-closed filehandle. It succeeds if you uncomment the line that forces use of Select.pm. This came up with Net::Curl testing. Perl can’t easily know whether libcurl has close()d the file descriptor, so this is a real-world scenario. Thank you! -FG ===== #!/usr/bin/env perl use strict; use warnings; # $ENV{'IO_ASYNC_LOOP'} = 'Select'; require IO::Async::Loop; require IO::Async::Handle; require IO::File; pipe my $r, my $w; my $loop = IO::Async::Loop->new(); print "ref: " . ref($loop) . $/; my $handle = IO::Async::Handle->new( read_handle => $r, on_read_ready => sub {}, ); $loop->add($handle); use POSIX; POSIX::close( fileno $r ); $loop->remove($handle); print "done\n"; =====
On Sun May 10 08:26:04 2020, felipe@felipegasper.com wrote: Show quoted text
> Hello, > > The script below will fail if the Epoll class is installed because the > underlying epoll_ctl gives EBADF for the already-closed filehandle. It > succeeds if you uncomment the line that forces use of Select.pm. > > This came up with Net::Curl testing. Perl can’t easily know whether > libcurl has close()d the file descriptor, so this is a real-world > scenario.
Yup, that's a real well-known problem with epoll. It's a fundamental problem with the underlying kernel mechanism being used, and the Linux developers' basic response to that is "well don't do that" :( Other than just ignoring the EBADF error there isn't a lot we can do about it from userland. -- Paul Evans
Subject: Re: [rt.cpan.org #132537] EBADF when removing a handle whose FD is closed
Date: Sun, 10 May 2020 09:21:38 -0400
To: bug-IO-Async-Loop-Epoll [...] rt.cpan.org
From: Felipe Gasper <felipe [...] felipegasper.com>
Show quoted text
> On May 10, 2020, at 9:00 AM, Paul Evans via RT <bug-IO-Async-Loop-Epoll@rt.cpan.org> wrote: > > <URL: https://rt.cpan.org/Ticket/Display.html?id=132537 > > > On Sun May 10 08:26:04 2020, felipe@felipegasper.com wrote:
>> Hello, >> >> The script below will fail if the Epoll class is installed because the >> underlying epoll_ctl gives EBADF for the already-closed filehandle. It >> succeeds if you uncomment the line that forces use of Select.pm. >> >> This came up with Net::Curl testing. Perl can’t easily know whether >> libcurl has close()d the file descriptor, so this is a real-world >> scenario.
> > Yup, that's a real well-known problem with epoll. It's a fundamental problem with the underlying kernel mechanism being used, and the Linux developers' basic response to that is "well don't do that" :( > > Other than just ignoring the EBADF error there isn't a lot we can do about it from userland.
Thank you for your quick response! Yeah I’m familiar with the kernel interface issue and actually tend to agree with the kernelers on this one. Catching/ignoring EBADF seems like something this module ought to do internally, since in principle the Epoll implementation ought to be interchangeable with the Select and Poll ones, right? -FG