From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 07E612017E for ; Mon, 28 Nov 2022 05:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613558; bh=XR9TSY0x4/kKyUlaGpQDNyt2TdwBUAepLokVGnATiTg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wyYB0BK3gxkDrn5vcZcHaG+6L/oQ7G33vCj/u2615UG+JSC9Qaw6qdMspITSiWP1/ O5yBcPFbxOjOdUHX25WywvyS8+XGA2Hk73Lh2PnLodqGkgsD7ylHHP14gKzNUt9RTM CPY0gKb186uyzoQaZtLGJlyAvpGc6B/tvmZznmeg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 26/95] lei_mirror: reduce scope of v2 lock Date: Mon, 28 Nov 2022 05:31:23 +0000 Message-Id: <20221128053232.291618-27-e@80x24.org> In-Reply-To: <20221128053232.291618-1-e@80x24.org> References: <20221128053232.291618-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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. --- lib/PublicInbox/LeiMirror.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) ];