about summary refs log tree commit homepage
path: root/lib/PublicInbox/PktOp.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/PktOp.pm')
-rw-r--r--lib/PublicInbox/PktOp.pm19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/PublicInbox/PktOp.pm b/lib/PublicInbox/PktOp.pm
index 4c434566..1bcdd799 100644
--- a/lib/PublicInbox/PktOp.pm
+++ b/lib/PublicInbox/PktOp.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # op dispatch socket, reads a message, runs a sub
@@ -6,12 +6,11 @@
 # Used for lei_xsearch and maybe other things
 # "command" => [ $sub, @fixed_operands ]
 package PublicInbox::PktOp;
-use strict;
-use v5.10.1;
+use v5.12;
 use parent qw(PublicInbox::DS);
 use Errno qw(EAGAIN ECONNRESET);
 use PublicInbox::Syscall qw(EPOLLIN);
-use Socket qw(AF_UNIX MSG_EOR SOCK_SEQPACKET);
+use Socket qw(AF_UNIX SOCK_SEQPACKET);
 use PublicInbox::IPC qw(ipc_freeze ipc_thaw);
 use Scalar::Util qw(blessed);
 
@@ -32,7 +31,7 @@ sub pair {
 
 sub pkt_do { # for the producer to trigger event_step in consumer
         my ($self, $cmd, @args) = @_;
-        send($self->{op_p}, @args ? "$cmd\0".ipc_freeze(\@args) : $cmd, MSG_EOR)
+        send($self->{op_p}, @args ? "$cmd\0".ipc_freeze(\@args) : $cmd, 0)
 }
 
 sub event_step {
@@ -55,7 +54,15 @@ sub event_step {
         my $op = $self->{ops}->{$cmd //= $msg};
         if ($op) {
                 my ($obj, @args) = (@$op, @pargs);
-                blessed($obj) ? $obj->$cmd(@args) : $obj->(@args);
+                if (blessed($args[0]) && $args[0]->can('do_env')) {
+                        my $lei = shift @args;
+                        $lei->do_env($obj, @args);
+                } elsif (blessed($obj)) {
+                        $obj->can('do_env') ? $obj->do_env($cmd, @args)
+                                                : $obj->$cmd(@args);
+                } else {
+                        $obj->(@args);
+                }
         } elsif ($msg ne '') {
                 die "BUG: unknown message: `$cmd'";
         }