about summary refs log tree commit homepage
path: root/lib/PublicInbox/Select.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Select.pm')
-rw-r--r--lib/PublicInbox/Select.pm6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/PublicInbox/Select.pm b/lib/PublicInbox/Select.pm
index 5cb7aff3..face8edc 100644
--- a/lib/PublicInbox/Select.pm
+++ b/lib/PublicInbox/Select.pm
@@ -8,6 +8,7 @@
 package PublicInbox::Select;
 use v5.12;
 use PublicInbox::Syscall qw(EPOLLONESHOT EPOLLIN EPOLLOUT);
+use Errno;
 
 sub new { bless {}, __PACKAGE__ } # fd => events
 
@@ -19,8 +20,9 @@ sub ep_wait {
                 vec($wvec, $fd, 1) = 1 if $ev & EPOLLOUT;
         }
         @$events = ();
-        my $n = select($rvec, $wvec, undef, $msec < 0 ? undef : ($msec/1000));
-        return if $n == 0;
+        my $to = $msec < 0 ? undef : ($msec/1000);
+        my $n = select $rvec, $wvec, undef, $to or return; # timeout expired
+        return if $n < 0 && $! == Errno::EINTR; # caller recalculates timeout
         die "select: $!" if $n < 0;
         while (my ($fd, $ev) = each %$self) {
                 if (vec($rvec, $fd, 1) || vec($wvec, $fd, 1)) {