]> Sergey Matveev's repositories - public-inbox.git/commitdiff
input_pipe: account for undefined {sock}
authorEric Wong <e@80x24.org>
Tue, 26 Oct 2021 10:35:57 +0000 (10:35 +0000)
committerEric Wong <e@80x24.org>
Tue, 26 Oct 2021 17:43:58 +0000 (17:43 +0000)
It's possible for ->event_step to fire twice due to ->requeue
with EPOLLET (but not EPOLLONESHOT).  So account for that and
avoid causing event loop errors as a result.

lib/PublicInbox/InputPipe.pm

index 00813a0701b172d4688997d3bf27116f98e4c15c..e1e26e20b9d287ba779bd6f32a9ad81c8f8a06d9 100644 (file)
@@ -18,7 +18,7 @@ sub consume {
 
 sub event_step {
        my ($self) = @_;
-       my $r = sysread($self->{sock}, my $rbuf, 65536);
+       my $r = sysread($self->{sock} // return, my $rbuf, 65536);
        if ($r) {
                $self->{cb}->(@{$self->{args} // []}, $rbuf);
                return $self->requeue; # may be regular file or pipe