From: Eric Wong Date: Thu, 4 Sep 2025 19:22:25 +0000 (+0000) Subject: ipc: use read_all to deal with short reads X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b6e1c8a0596909a908a58cb847f6232e59059b36;p=thirdparty%2Fpublic-inbox.git ipc: use read_all to deal with short reads The `read' perlop can still return short reads with the default IO layer on pipes. --- 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); }