diff options
author | Eric Wong <e@80x24.org> | 2023-11-02 09:35:37 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-11-03 06:39:33 +0000 |
commit | 3aa444b4c4eef1c40a49e5db191eb844c6624b58 (patch) | |
tree | 73b724bfc7b76c7306497514e2f63177e022b3be /lib/PublicInbox/Gcf2.pm | |
parent | 17ceb50fe054384dc65fdcbdc786dd125bf07947 (diff) | |
download | public-inbox-3aa444b4c4eef1c40a49e5db191eb844c6624b58.tar.gz |
readline (<FH>) isn't wrapped by autodie, and there's no way to know if read(2) errors truncated the readline output. IO::Handle->error isn't reliable on Perl < v5.34. Thus, combining the `eof' and `close' (combined with autodie) is the only way we can detect read(2) errors (injected via strace) when called via `readline' (aka <$fh>). Neither using `eof' nor `close' alone is sufficient, they must be combined to detect errors from buffered `readline'.
Diffstat (limited to 'lib/PublicInbox/Gcf2.pm')
-rw-r--r-- | lib/PublicInbox/Gcf2.pm | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/PublicInbox/Gcf2.pm b/lib/PublicInbox/Gcf2.pm index 502bf33a..6ee0d7d9 100644 --- a/lib/PublicInbox/Gcf2.pm +++ b/lib/PublicInbox/Gcf2.pm @@ -11,6 +11,7 @@ use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC); use IO::Handle; # autoflush use PublicInbox::Git; use PublicInbox::Lock; +use autodie qw(close); BEGIN { use autodie; @@ -81,6 +82,7 @@ sub add_alt ($$) { # See https://bugs.debian.org/975607 if (open(my $fh, '<', "$objdir/info/alternates")) { chomp(my @abs_alt = grep(m!^/!, <$fh>)); + $fh = eof($fh) | close $fh; # detect readline errors $gcf2->add_alternate($_) for @abs_alt; } $gcf2->add_alternate($objdir); |