From 50c074ec9e030f05b53773dafb29d6098f58b56c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 2 Feb 2021 22:11:37 -1000 Subject: lei: propagate curl errors, improve internal consistency IO::Uncompress::Gunzip seems to be losing $? when closing PublicInbox::ProcessPipe. To workaround this, do a synchronous waitpid ourselves to force proper $? reporting update tests to use the new --only feature for testing invalid URLs. This improves internal code consistency by having {pkt_op} parse the same ASCII-only protocol script/lei understands. We no longer pass {sock} to worker processes at all, further reducing FD pressure on per-user limits. --- lib/PublicInbox/PktOp.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/PktOp.pm') diff --git a/lib/PublicInbox/PktOp.pm b/lib/PublicInbox/PktOp.pm index 40c7262a..10d76da0 100644 --- a/lib/PublicInbox/PktOp.pm +++ b/lib/PublicInbox/PktOp.pm @@ -4,8 +4,7 @@ # op dispatch socket, reads a message, runs a sub # There may be multiple producers, but (for now) only one consumer # Used for lei_xsearch and maybe other things -# "literal" => [ sub, @operands ] -# /regexp/ => [ sub, @operands ] +# "command" => [ $sub, @fixed_operands ] package PublicInbox::PktOp; use strict; use v5.10.1; @@ -57,11 +56,19 @@ sub event_step { $self->close; die "recv: $!"; } - my ($cmd, $pargs) = split(/\0/, $msg, 2); + my ($cmd, @pargs); + if (index($msg, "\0") > 0) { + ($cmd, my $pargs) = split(/\0/, $msg, 2); + @pargs = @{ipc_thaw($pargs)}; + } else { + # for compatibility with the script/lei in client mode, + # it doesn't load Sereal||Storable for startup speed + ($cmd, @pargs) = split(/ /, $msg); + } my $op = $self->{ops}->{$cmd //= $msg}; die "BUG: unknown message: `$cmd'" unless $op; my ($sub, @args) = @$op; - $sub->(@args, $pargs ? ipc_thaw($pargs) : ()); + $sub->(@args, @pargs); return $self->close if $msg eq ''; # close on EOF } while (1); } -- cgit v1.2.3-24-ge0c7