]> Sergey Matveev's repositories - public-inbox.git/commitdiff
spamc: retry on EINTR
authorEric Wong <e@80x24.org>
Sat, 24 Jun 2017 00:52:10 +0000 (00:52 +0000)
committerEric Wong <e@80x24.org>
Mon, 26 Jun 2017 03:07:46 +0000 (03:07 +0000)
Signals can fire on us at any time if we're using blocking sysread.

lib/PublicInbox/Spamcheck/Spamc.pm

index 30eec95cc6fad519c02980fb7cbb16adec19ce88..ba8e44a489c031b8b237bec466fc2dfccb72943b 100644 (file)
@@ -29,10 +29,14 @@ sub spamcheck {
                my $buf = '';
                $out = \$buf;
        }
+again:
        do {
                $r = sysread($fh, $$out, 65536, length($$out));
        } while (defined($r) && $r != 0);
-       defined $r or die "read failed: $!";
+       unless (defined $r) {
+               goto again if $!{EINTR};
+               die "read failed: $!";
+       }
        close $fh or die "close failed: $!";
        waitpid($pid, 0);
        ($? || $$out eq '') ? 0 : 1;