diff options
author | Eric Wong <e@80x24.org> | 2021-01-10 12:15:12 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-01-12 03:51:42 +0000 |
commit | 6cc0e6870cb4950c08646769f2a7e30729b7d409 (patch) | |
tree | 13eb8e9cd433b215a8980ecbc6c7d1a741473466 /lib/PublicInbox/CmdIPC1.pm | |
parent | 0c89ebd477d1c7a695a0a0b3023c0d41abe573fa (diff) | |
download | public-inbox-6cc0e6870cb4950c08646769f2a7e30729b7d409.tar.gz |
Actually, sending 4 FDs will be useful for lei internal xsearch work once we start accepting input from stdin. It won't be used with the lightweight lei(1) client, however. For WWW (eventually), a single FD may be enough.
Diffstat (limited to 'lib/PublicInbox/CmdIPC1.pm')
-rw-r--r-- | lib/PublicInbox/CmdIPC1.pm | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/PublicInbox/CmdIPC1.pm b/lib/PublicInbox/CmdIPC1.pm index 0eed8bed..de6e54ef 100644 --- a/lib/PublicInbox/CmdIPC1.pm +++ b/lib/PublicInbox/CmdIPC1.pm @@ -10,17 +10,19 @@ BEGIN { eval { require IO::FDPass; # XS, available in all major distros no warnings 'once'; -*send_cmd1 = sub ($$$$$$) { # (sock, in, out, err, buf, flags) = @_; - for (1..3) { - IO::FDPass::send(fileno($_[0]), $_[$_]) or +*send_cmd1 = sub ($$$$) { # (sock, fds, buf, flags) = @_; + my ($sock, $fds, undef, $flags) = @_; + for my $fd (@$fds) { + IO::FDPass::send(fileno($sock), $fd) or die "IO::FDPass::send: $!"; } - send($_[0], $_[4], $_[5]) or die "send $!"; + send($sock, $_[2], $flags) or die "send $!"; }; -*recv_cmd1 = sub ($$$) { - my ($s, undef, $len) = @_; - my @fds = map { IO::FDPass::recv(fileno($s)) } (0..2); +*recv_cmd1 = sub ($$$;$) { + my ($s, undef, $len, $nfds) = @_; + $nfds //= 3; + my @fds = map { IO::FDPass::recv(fileno($s)) } (1..$nfds); recv($s, $_[1], $len, 0) // die "recv: $!"; length($_[1]) == 0 ? () : @fds; }; |