From b6e1c8a0596909a908a58cb847f6232e59059b36 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 4 Sep 2025 19:22:25 +0000 Subject: [PATCH] ipc: use read_all to deal with short reads The `read' perlop can still return short reads with the default IO layer on pipes. --- lib/PublicInbox/IPC.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm index f4d83430e..b744b1aaa 100644 --- a/lib/PublicInbox/IPC.pm +++ b/lib/PublicInbox/IPC.pm @@ -14,7 +14,7 @@ use autodie qw(close pipe read send socketpair); use Errno qw(EAGAIN EINTR); use Carp qw(croak); use PublicInbox::DS qw(awaitpid); -use PublicInbox::IO; +use PublicInbox::IO qw(read_all); use PublicInbox::Spawn; use PublicInbox::OnDestroy; use PublicInbox::WQWorker; @@ -58,8 +58,8 @@ sub _get_rec ($) { my ($r) = @_; my $len = <$r> // return; chop($len) eq "\n" or croak "no LF byte in $len"; - my $n = read($r, my $buf, $len); - $n == $len or croak "short read: $n != $len"; + my $buf = read_all $r, $len; + length($buf) == $len or croak "short read: ",length($buf)," != $len"; ipc_thaw($buf); } -- 2.47.3