diff options
author | Eric Wong <e@80x24.org> | 2021-03-04 17:03:13 +0800 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-03-04 14:29:39 -0400 |
commit | b9524082ba39e66516d5422fa141e330f2ffef33 (patch) | |
tree | d30854af4f9f2a1605d33e051aeea68af3ce3dd5 | |
parent | d74c4c9c2802b88a627dbc55e8e10cbc57e82b1d (diff) | |
download | public-inbox-b9524082ba39e66516d5422fa141e330f2ffef33.tar.gz |
We must ensure pkt_op_p doesn't live beyond the scope of ->do_query in the top-level lei-daemon, otherwise it can leave a stray socket hanging around in case of exceptions.
-rw-r--r-- | lib/PublicInbox/LeiXSearch.pm | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 45815180..059aa284 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -416,6 +416,11 @@ 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}; @@ -431,6 +436,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); $lei->{1}->autoflush(1); $lei->start_pager if delete $lei->{need_pager}; |