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.0 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 D1945203C8 for ; Mon, 28 Nov 2022 05:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613569; bh=YyzNtjWk8BAqiq4u7ah3bTsIxkvsdvBIB3v/lwYJxjw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=M3W9Z/9uHZSxmn9ZZa7vpAvGkapq3Tx359u25fqGaqU4Pz2fC5Evf7tySQsEpkRte F7LWZ8bOUzOR67UzbUHJfPQ+tVket9aze0RHx6jUtbDCFfsyWLq+AxhHGo+VPlBbg2 3iUT/RuTE8+LI4j7QpgxjAy5AmLbxpmJQ0jcHliY= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 80/95] lei_mirror: remove janky mirror.done stamp file Date: Mon, 28 Nov 2022 05:32:17 +0000 Message-Id: <20221128053232.291618-81-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: This makes a fundamental (and overdue) change to the core of lei in how it handles child errors. Every process which generates or receives a child error will remember it before passing it on. This ensures _wq_done_wait callbacks will know of prior errors aside from $? when it runs. --- lib/PublicInbox/LEI.pm | 3 +-- lib/PublicInbox/LeiMirror.pm | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 8a14ace4..b78d70de 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -544,12 +544,11 @@ sub child_error { # passes non-fatal curl exit codes to user local $current_lei = $self; $child_error ||= 1 << 8; warn(substr($msg, -1, 1) eq "\n" ? $msg : "$msg\n") if defined $msg; + $self->{child_error} ||= $child_error; if ($self->{pkt_op_p}) { # to top lei-daemon $self->{pkt_op_p}->pkt_do('child_error', $child_error); } elsif ($self->{sock}) { # to lei(1) client send($self->{sock}, "child_error $child_error", MSG_EOR); - } else { # non-lei admin command - $self->{child_error} ||= $child_error; } # else noop if client disconnected } diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index b982f919..b8b6b504 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -30,12 +30,9 @@ sub keep_going ($) { sub _wq_done_wait { # dwaitpid callback (via wq_eof) my ($arg, $pid) = @_; my ($mrr, $lei) = @$arg; - my $f = "$mrr->{dst}/mirror.done"; if ($?) { $lei->child_error($?); - } elsif (!$mrr->{dry_run} && !unlink($f)) { - warn("unlink($f): $!\n") unless $!{ENOENT}; - } else { + } elsif (!$lei->{child_error}) { if (!$mrr->{dry_run} && $lei->{cmd} ne 'public-inbox-clone') { require PublicInbox::LeiAddExternal; PublicInbox::LeiAddExternal::_finish_add_external( @@ -249,7 +246,6 @@ sub index_cloned_inbox { PublicInbox::Admin::index_inbox($ibx, undef, $opt); } return if defined $self->{cur_dst}; # one of many repos to clone - open my $x, '>', "$self->{dst}/mirror.done"; # for _wq_done_wait } sub run_reap { @@ -1082,7 +1078,6 @@ EOM } dump_manifest($m => $ft) if delete($self->{chg}->{manifest}) || $mis; ft_rename($ft, $manifest, 0666); - open my $x, '>', "$self->{dst}/mirror.done"; # for _wq_done_wait } sub start_clone_url {