From 4f868db3675eeee5994edc4fe79a9a2583623747 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 24 Jun 2019 02:52:56 +0000 Subject: ds: reimplement IO::Poll support to look like epoll At least the subset of epoll we use. EPOLLET might be difficult to emulate if we end up using it. --- lib/PublicInbox/DS.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox/DS.pm') diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index d6ef0b8d..e3479e66 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -142,15 +142,17 @@ sub _InitPoller return if $DoneInit; $DoneInit = 1; - if (!PublicInbox::Syscall::epoll_defined()) { - $Epoll = eval { - require PublicInbox::DSKQXS; - PublicInbox::DSKQXS->import; - PublicInbox::DSKQXS->new; - }; - } else { + if (PublicInbox::Syscall::epoll_defined()) { $Epoll = epoll_create(); set_cloexec($Epoll) if (defined($Epoll) && $Epoll >= 0); + } else { + my $cls; + for (qw(DSKQXS DSPoll)) { + $cls = "PublicInbox::$_"; + last if eval "require $cls"; + } + $cls->import; + $Epoll = $cls->new; } *EventLoop = *EpollEventLoop; } -- cgit v1.2.3-24-ge0c7