about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-16 09:29:50 +0000
committerEric Wong <e@80x24.org>2021-10-16 10:37:06 +0000
commitaa0102f777d0155fa098b1e79eb9f4e8d1769279 (patch)
tree9c09149f00997be62ae66c6f6174f8f76f8ed191
parent9ee1798e270f44c94bd13ca8becbac393535005b (diff)
downloadpublic-inbox-aa0102f777d0155fa098b1e79eb9f4e8d1769279.tar.gz
Sigfd->event_step needs priority over WQWorkers (and everything
else).  Do that by running once per event_loop iteration rather
than looping inside event_step.  This lowers throughput since it
requires more syscalls, but that's the price of fairness.
-rw-r--r--lib/PublicInbox/WQWorker.pm18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/PublicInbox/WQWorker.pm b/lib/PublicInbox/WQWorker.pm
index 48b901bb..950bd170 100644
--- a/lib/PublicInbox/WQWorker.pm
+++ b/lib/PublicInbox/WQWorker.pm
@@ -6,7 +6,7 @@ package PublicInbox::WQWorker;
 use strict;
 use v5.10.1;
 use parent qw(PublicInbox::DS);
-use PublicInbox::Syscall qw(EPOLLIN EPOLLEXCLUSIVE EPOLLET);
+use PublicInbox::Syscall qw(EPOLLIN EPOLLEXCLUSIVE);
 use Errno qw(EAGAIN ECONNRESET);
 use IO::Handle (); # blocking
 
@@ -14,19 +14,19 @@ sub new {
         my ($cls, $wq, $sock) = @_;
         $sock->blocking(0);
         my $self = bless { sock => $sock, wq => $wq }, $cls;
-        $self->SUPER::new($sock, EPOLLEXCLUSIVE|EPOLLIN|EPOLLET);
+        $self->SUPER::new($sock, EPOLLEXCLUSIVE|EPOLLIN);
         $self;
 }
 
 sub event_step {
         my ($self) = @_;
-        my $n;
-        do {
-                $n = $self->{wq}->recv_and_run($self->{sock});
-        } while ($n);
-        return if !defined($n) && $! == EAGAIN; # likely
-        warn "wq worker error: $!\n" if !defined($n) && $! != ECONNRESET;
-        $self->{wq}->wq_atexit_child if $self->{sock} == $self->{wq}->{-wq_s2};
+        my $n = $self->{wq}->recv_and_run($self->{sock}) and return;
+        unless (defined $n) {
+                return if $! == EAGAIN;
+                warn "recvmsg: $!" if $! != ECONNRESET;
+        }
+        $self->{sock} == $self->{wq}->{-wq_s2} and
+                $self->{wq}->wq_atexit_child;
         $self->close; # PublicInbox::DS::close
 }