]> Sergey Matveev's repositories - public-inbox.git/commitdiff
{dir,inbox}idle: use level-triggered epoll
authorEric Wong <e@80x24.org>
Mon, 4 Oct 2021 08:26:33 +0000 (08:26 +0000)
committerEric Wong <e@80x24.org>
Mon, 4 Oct 2021 09:51:30 +0000 (09:51 +0000)
Both read(2) on inotify and kevent(2) return a finite amount of
events.  Let the kernel notify us again in cases where we'd
need to retry instead of looping ourselves.  This can prevent
missed/delayed notifications while still ensuring fairness in
busy event loops.

lib/PublicInbox/DirIdle.pm
lib/PublicInbox/InboxIdle.pm

index d572c2749f7fc750e0a3ae3cbcf8748b1263ef10..c9a293e9355a222bf3416fcd4617b3276d41cded 100644 (file)
@@ -5,7 +5,7 @@
 package PublicInbox::DirIdle;
 use strict;
 use parent 'PublicInbox::DS';
-use PublicInbox::Syscall qw(EPOLLIN EPOLLET);
+use PublicInbox::Syscall qw(EPOLLIN);
 use PublicInbox::In2Tie;
 
 my ($MAIL_IN, $MAIL_GONE, $ino_cls);
@@ -38,7 +38,7 @@ sub new {
        if ($ino_cls) {
                $inot = $ino_cls->new or die "E: $ino_cls->new: $!";
                my $io = PublicInbox::In2Tie::io($inot);
-               $self->SUPER::new($io, EPOLLIN | EPOLLET);
+               $self->SUPER::new($io, EPOLLIN);
        } else {
                require PublicInbox::FakeInotify;
                $inot = PublicInbox::FakeInotify->new; # starts timer
index 4d74b3545902f7882d570da28176d6d9b83e3272..2781b3e15bb96c290be28169009705a941662d08 100644 (file)
@@ -7,7 +7,7 @@
 package PublicInbox::InboxIdle;
 use strict;
 use parent qw(PublicInbox::DS);
-use PublicInbox::Syscall qw(EPOLLIN EPOLLET);
+use PublicInbox::Syscall qw(EPOLLIN);
 my $IN_MODIFY = 0x02; # match Linux inotify
 my $ino_cls;
 if ($^O eq 'linux' && eval { require Linux::Inotify2; 1 }) {
@@ -73,7 +73,7 @@ sub new {
        if ($ino_cls) {
                $inot = $ino_cls->new or die "E: $ino_cls->new: $!";
                my $io = PublicInbox::In2Tie::io($inot);
-               $self->SUPER::new($io, EPOLLIN | EPOLLET);
+               $self->SUPER::new($io, EPOLLIN);
        } else {
                require PublicInbox::FakeInotify;
                $inot = PublicInbox::FakeInotify->new;