X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLeiUp.pm;h=df65cb9b8474af2e3f6c644ba39271e70a357b25;hb=f912df6e26aac8c20b4fa56dd69bc09c88f5403d;hp=719736e8597ef7efcd30f8504b68d922773f3f13;hpb=e482a9fb713db1c14b52d6db05049842605764e2;p=public-inbox.git diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm index 719736e8..df65cb9b 100644 --- a/lib/PublicInbox/LeiUp.pm +++ b/lib/PublicInbox/LeiUp.pm @@ -166,7 +166,15 @@ sub event_step { # runs via PublicInbox::DS::requeue push(@m, $o) if !@m || $m[-1] !~ s/\n\z/$o\n/; $cb->(@m); }; - $l->{-up1} = $self; + $l->{-up1} = $self; # for LeiUp1->DESTROY + delete @$l{qw(-socks -event_init_done)}; + my ($op_c, $op_p) = PublicInbox::PktOp->pair; + $self->{unref_on_destroy} = $op_c->{sock}; # to cleanup $lei->{-socks} + $lei->pkt_ops($op_c->{ops} //= {}); # errors from $l -> script/lei + push @{$lei->{-socks}}, $op_c->{sock}; # script/lei signals to $l + $l->{sock} = $op_p->{op_p}; # receive signals from op_c->{sock} + $op_c = $op_p = undef; + eval { $l->dispatch('up', $self->{out}) }; $lei->child_error(0, $@) if $@ || $l->{failed}; # lei->fail() } @@ -175,6 +183,9 @@ sub DESTROY { my ($self) = @_; my $lei = $self->{lei}; # the original, from lei_up return if $lei->{daemon_pid} != $$; + my $sock = delete $self->{unref_on_destroy}; + my $s = $lei->{-socks} // []; + @$s = grep { $_ != $sock } @$s; my $out = shift(@{$lei->{-upq}}) or return; PublicInbox::DS::requeue(nxt($lei, $out, $self->{op_p})); }