about summary refs log tree commit homepage
path: root/lib/PublicInbox/CmdIPC4.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-13 19:06:14 -1200
committerEric Wong <e@80x24.org>2021-01-14 23:14:08 +0000
commit7dd5b28cb9bdcfa262ddad47d7f033f600675dc3 (patch)
treec55a8afc5163ad33b37911fabbfd699b1b953143 /lib/PublicInbox/CmdIPC4.pm
parentb0898d18efbc8f646b736088f9600b87be88f91e (diff)
downloadpublic-inbox-7dd5b28cb9bdcfa262ddad47d7f033f600675dc3.tar.gz
We'll ensure our {send,recv}_cmd4 implementations are
consistent w.r.t. non-blocking and interrupted sockets.

We'll also support receiving messages without FDs associated
so we don't have to send dummy FDs to keep receivers from
reporting EOF.
Diffstat (limited to 'lib/PublicInbox/CmdIPC4.pm')
-rw-r--r--lib/PublicInbox/CmdIPC4.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/CmdIPC4.pm b/lib/PublicInbox/CmdIPC4.pm
index c4fcb0d6..c244f6a1 100644
--- a/lib/PublicInbox/CmdIPC4.pm
+++ b/lib/PublicInbox/CmdIPC4.pm
@@ -18,17 +18,17 @@ no warnings 'once';
         my $mh = Socket::MsgHdr->new(buf => $_[2]);
         $mh->cmsghdr(SOL_SOCKET, SCM_RIGHTS,
                         pack('i' x scalar(@$fds), @$fds));
-        Socket::MsgHdr::sendmsg($sock, $mh, $flags) or die "sendmsg: $!";
+        Socket::MsgHdr::sendmsg($sock, $mh, $flags);
 };
 
 *recv_cmd4 = sub ($$$) {
         my ($s, undef, $len) = @_; # $_[1] = destination buffer
         my $mh = Socket::MsgHdr->new(buflen => $len, controllen => 256);
-        my $r = Socket::MsgHdr::recvmsg($s, $mh, 0) // die "recvmsg: $!";
+        my $r = Socket::MsgHdr::recvmsg($s, $mh, 0) // return ($_[1] = undef);
         $_[1] = $mh->buf;
         return () if $r == 0;
         my (undef, undef, $data) = $mh->cmsghdr;
-        unpack('i' x (length($data) / 4), $data);
+        defined($data) ? unpack('i' x (length($data) / 4), $data) : ();
 };
 
 } } # /eval /BEGIN