diff options
author | Eric Wong <e@80x24.org> | 2021-03-23 11:48:08 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-03-24 01:33:26 +0000 |
commit | 97caa1fe259cd6904573f36e0ac078a269b6ec5f (patch) | |
tree | 1babb08442553884028f9177ce471188fbfd5c76 /lib/PublicInbox/LeiImport.pm | |
parent | d39ff2cf4400b87bf6f51d7fe9f4b0e2a72bf679 (diff) | |
download | public-inbox-97caa1fe259cd6904573f36e0ac078a269b6ec5f.tar.gz |
Instead of creating a short-lived circular reference, ensure they don't exist in the first place. Note the following changes to hold an extra ref to $sto: - $self->_lei_store(1)->write_prepare($self); + my $sto = $self->_lei_store(1); + $sto->write_prepare($self); I'm not a perlguts expert, but I actually wanted to switch to the one-line version for LeiImport, but xt/lei-auth-fail.t was getting stuck for some reason. It seems the extra ref to the LeiStore ($sto) object is necessary.
Diffstat (limited to 'lib/PublicInbox/LeiImport.pm')
-rw-r--r-- | lib/PublicInbox/LeiImport.pm | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm index 991c84f2..9da6b7f9 100644 --- a/lib/PublicInbox/LeiImport.pm +++ b/lib/PublicInbox/LeiImport.pm @@ -58,9 +58,13 @@ sub net_merge_complete { # callback used by LeiAuth $self->wq_close(1); } -sub import_start { - my ($lei) = @_; - my $self = $lei->{imp}; +sub lei_import { # the main "lei import" method + my ($lei, @inputs) = @_; + my $sto = $lei->_lei_store(1); + $sto->write_prepare($lei); + my $self = bless {}, __PACKAGE__; + $self->{-import_kw} = $lei->{opt}->{kw} // 1; + $self->prepare_inputs($lei, \@inputs) or return; $lei->ale; # initialize for workers to read my $j = $lei->{opt}->{jobs} // scalar(@{$self->{inputs}}) || 1; if (my $net = $lei->{net}) { @@ -79,16 +83,6 @@ sub import_start { while ($op && $op->{sock}) { $op->event_step } } -sub lei_import { # the main "lei import" method - my ($lei, @inputs) = @_; - my $sto = $lei->_lei_store(1); - $sto->write_prepare($lei); - my $self = $lei->{imp} = bless {}, __PACKAGE__; - $self->{-import_kw} = $lei->{opt}->{kw} // 1; - $self->prepare_inputs($lei, \@inputs) or return; - import_start($lei); -} - no warnings 'once'; *ipc_atfork_child = \&PublicInbox::LeiInput::input_only_atfork_child; |