about summary refs log tree commit homepage
path: root/lib/PublicInbox/PktOp.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-02 22:11:37 -1000
committerEric Wong <e@80x24.org>2021-02-04 01:37:09 +0000
commit50c074ec9e030f05b53773dafb29d6098f58b56c (patch)
tree25b7e8f4716c6ff677d806855655a031edebaf4c /lib/PublicInbox/PktOp.pm
parentc7420334c0d69bf948ad670c822753334e4664a8 (diff)
downloadpublic-inbox-50c074ec9e030f05b53773dafb29d6098f58b56c.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/PktOp.pm')
-rw-r--r--lib/PublicInbox/PktOp.pm15
1 files changed, 11 insertions, 4 deletions
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);
 }