From: Eric Wong Date: Mon, 28 Nov 2022 05:31:23 +0000 (+0000) Subject: lei_mirror: reduce scope of v2 lock X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=cfabf09dabe2f6780e2e3d29b44a2e8cccab8b77 lei_mirror: reduce scope of v2 lock Guarding against parallel clones isn't realistic, really, only setting up all.git, and even then, I'm not 100% sure the lock is useful. --- diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 9c457fca..0a93ed44 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -377,9 +377,11 @@ sub v1_done { # called via OnDestroy sub v2_done { # called via OnDestroy my ($self) = @_; return if $self->{dry_run} || !$LIVE; + my $dst = $self->{cur_dst} // $self->{dst}; + my $lk = bless { lock_path => "$dst/inbox.lock" }, 'PublicInbox::Lock'; + my $lck = $lk->lock_for_scope($$); _write_inbox_config($self); require PublicInbox::MultiGit; - my $dst = $self->{cur_dst} // $self->{dst}; my $mg = PublicInbox::MultiGit->new($dst, 'all.git', 'git'); $mg->fill_alternates; for my $i ($mg->git_epochs) { $mg->epoch_cfg_set($i) } @@ -393,7 +395,7 @@ sub v2_done { # called via OnDestroy chmod($st[2] & 0555, $edst) or die "chmod(a-w, $edst): $!"; } write_makefile($dst, 2); - delete $self->{-locked} // die "BUG: $dst not locked"; # unlock + undef $lck; # unlock index_cloned_inbox($self, 2); } @@ -443,7 +445,6 @@ failed to extract epoch number from $src (!$self->{dry_run} && !-d $dst) and File::Path::mkpath($dst); require PublicInbox::Lock; - my $lk = bless { lock_path => "$dst/inbox.lock" }, 'PublicInbox::Lock'; my $fini = PublicInbox::OnDestroy->new($$, \&v2_done, $task); $lei->{opt}->{'inbox-config'} =~ /\A(?:always|v2)\z/s and @@ -451,7 +452,6 @@ failed to extract epoch number from $src _get_txt_start($task, 'description', $fini); - $task->{-locked} = $lk->lock_for_scope($$) if !$self->{dry_run}; my @cmd = clone_cmd($lei, my $opt = {}); while (@src_edst && !$lei->{child_error}) { my $cmd = [ @$pfx, @cmd, splice(@src_edst, 0, 2) ];