unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/5] spamc: retry on EINTR
Date: Mon, 26 Jun 2017 03:15:42 +0000	[thread overview]
Message-ID: <20170626031545.11879-3-e@80x24.org> (raw)
In-Reply-To: <20170626031545.11879-1-e@80x24.org>

Signals can fire on us at any time if we're using blocking sysread.
---
 lib/PublicInbox/Spamcheck/Spamc.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/Spamcheck/Spamc.pm b/lib/PublicInbox/Spamcheck/Spamc.pm
index 30eec95..ba8e44a 100644
--- a/lib/PublicInbox/Spamcheck/Spamc.pm
+++ b/lib/PublicInbox/Spamcheck/Spamc.pm
@@ -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;
-- 
EW


  parent reply	other threads:[~2017-06-26  3:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26  3:15 [PATCH 0/5] watch: various bugfixes and fairness improvements Eric Wong
2017-06-26  3:15 ` [PATCH 1/5] watch: ensure HUP causes the scanner to be reloaded Eric Wong
2017-06-26  3:15 ` Eric Wong [this message]
2017-06-26  3:15 ` [PATCH 3/5] watch: improve fairness during full rescans Eric Wong
2017-06-26  4:01   ` Eric Wong
2017-06-26  3:15 ` [PATCH 4/5] watch: use "self-inotify-tempfile trick" for quit Eric Wong
2017-06-26  3:15 ` [PATCH 5/5] watch: commit changes to fast-import sooner Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170626031545.11879-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).