about summary refs log tree commit homepage
path: root/lib/PublicInbox/Listener.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-27 21:21:05 +0000
committerEric Wong <e@80x24.org>2019-06-29 19:59:00 +0000
commite37ac4015fa6f9616c845a73abc36ec5a21d57a7 (patch)
tree8a2b49d031e5da3e47c96141a12392a69d484b1b /lib/PublicInbox/Listener.pm
parent63eeb22554eb844cee274f71d3541446c28b328f (diff)
downloadpublic-inbox-e37ac4015fa6f9616c845a73abc36ec5a21d57a7.tar.gz
We don't need extra wakeups from the kernel when we know a
listener is already active.
Diffstat (limited to 'lib/PublicInbox/Listener.pm')
-rw-r--r--lib/PublicInbox/Listener.pm7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/PublicInbox/Listener.pm b/lib/PublicInbox/Listener.pm
index 94b2aed4..594dabb8 100644
--- a/lib/PublicInbox/Listener.pm
+++ b/lib/PublicInbox/Listener.pm
@@ -9,6 +9,7 @@ use base 'PublicInbox::DS';
 use Socket qw(SOL_SOCKET SO_KEEPALIVE IPPROTO_TCP TCP_NODELAY);
 use fields qw(post_accept);
 require IO::Handle;
+use PublicInbox::Syscall qw(EPOLLIN EPOLLEXCLUSIVE EPOLLET);
 
 sub new ($$$) {
         my ($class, $s, $cb) = @_;
@@ -17,15 +18,14 @@ sub new ($$$) {
         listen($s, 1024);
         IO::Handle::blocking($s, 0);
         my $self = fields::new($class);
-        $self->SUPER::new($s, PublicInbox::DS::EPOLLIN()|
-                              PublicInbox::DS::EPOLLEXCLUSIVE());
+        $self->SUPER::new($s, EPOLLIN|EPOLLET|EPOLLEXCLUSIVE);
         $self->{post_accept} = $cb;
         $self
 }
 
 sub event_step {
         my ($self) = @_;
-        my $sock = $self->{sock};
+        my $sock = $self->{sock} or return;
 
         # no loop here, we want to fairly distribute clients
         # between multiple processes sharing the same socket
@@ -35,6 +35,7 @@ sub event_step {
         if (my $addr = accept(my $c, $sock)) {
                 IO::Handle::blocking($c, 0); # no accept4 :<
                 $self->{post_accept}->($c, $addr, $sock);
+                $self->requeue;
         }
 }