diff options
author | Eric Wong <e@80x24.org> | 2021-03-24 14:23:31 +0500 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-03-24 23:01:19 +0000 |
commit | c5b52ce9b026e0a1cd5c32ffade1f08e544f4cdb (patch) | |
tree | 88bb441da037deb9a7afc1927d11d400018d3e2e /lib/PublicInbox/LeiXSearch.pm | |
parent | d33f1ef680f2e7bce511f1e18d6bb5b24650e17b (diff) | |
download | public-inbox-c5b52ce9b026e0a1cd5c32ffade1f08e544f4cdb.tar.gz |
We need to consistently ensure pkt_op_c doesn't lead to a long-lived circular reference if an exception is thrown in pre_augment. Maybe the API could be better, but this fixes an FD leak when attempting to --augment a FIFO. Followup-to: b9524082ba39e665 ("lei_xsearch: cleanup {pkt_op_p} on exceptions")
Diffstat (limited to 'lib/PublicInbox/LeiXSearch.pm')
-rw-r--r-- | lib/PublicInbox/LeiXSearch.pm | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index c6b82eeb..58b6cfc0 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -406,11 +406,6 @@ sub ipc_atfork_child { $self->SUPER::ipc_atfork_child; } -sub delete_pkt_op { # OnDestroy callback - my $unclosed_after_die = delete($_[0])->{pkt_op_p} or return; - close $unclosed_after_die; -} - sub do_query { my ($self, $lei) = @_; my $l2m = $lei->{l2m}; @@ -426,8 +421,7 @@ sub do_query { 'incr_start_query' => [ \&incr_start_query, $self, $l2m ], }; $lei->{auth}->op_merge($ops, $l2m) if $l2m && $lei->{auth}; - my $od = PublicInbox::OnDestroy->new($$, \&delete_pkt_op, $lei); - ($lei->{pkt_op_c}, $lei->{pkt_op_p}) = PublicInbox::PktOp->pair($ops); + my $end = $lei->pkt_op_pair($ops); $lei->{1}->autoflush(1); $lei->start_pager if delete $lei->{need_pager}; $lei->{ovv}->ovv_begin($lei); @@ -446,6 +440,7 @@ sub do_query { $lei->oldset, { lei => $lei }); my $op = delete $lei->{pkt_op_c}; delete $lei->{pkt_op_p}; + @$end = (); $self->{threads} = $lei->{opt}->{threads}; if ($l2m) { $l2m->net_merge_complete unless $lei->{auth}; |