]> Sergey Matveev's repositories - public-inbox.git/commitdiff
qspawn: use per-call quiet flag for solver
authorEric Wong <e@80x24.org>
Thu, 2 Jan 2020 09:24:59 +0000 (09:24 +0000)
committerEric Wong <e@80x24.org>
Fri, 3 Jan 2020 02:29:15 +0000 (02:29 +0000)
solver can spawn multiple processes per HTTP request, but
"git apply" failures are needlessly noisy due to corrupt
patches.  We also don't want to silence "git ls-files"
or "git update-index" errors using $env->{'qspawn.quiet'},
either, so this granularity is needed.

Admins can check for 500 errors in access logs to detect
(and reproduce) solver failures, anyways, so there's no
need to log every time "git apply" rejects a corrupt patch.

lib/PublicInbox/Qspawn.pm
lib/PublicInbox/SolverGit.pm

index 1a2b70e7b442e8a2373ebd2ae207d6555a6bab9e..65bb178aba44a216f73c221338aebd5f7a9dba92 100644 (file)
@@ -56,9 +56,7 @@ sub _do_spawn {
 
        ($self->{rpipe}, $self->{pid}) = popen_rd($cmd, $cmd_env, \%opts);
 
-       # drop any IO handles opt was holding open via $opt->{hold}
-       # No need to hold onto the descriptor once the child process has it.
-       $self->{args} = $cmd; # keep this around for logging
+       $self->{args} = $opts{quiet} ? undef : $cmd;
 
        if (defined $self->{pid}) {
                $limiter->{running}++;
@@ -108,7 +106,7 @@ sub waitpid_err ($$) {
 
        if ($err) {
                $self->{err} = $err;
-               if ($env && !$env->{'qspawn.quiet'}) {
+               if ($env && $self->{args}) {
                        log_err($env, join(' ', @{$self->{args}}) . ": $err");
                }
        }
index c9812b325cb98037cf6c785156d2a73291356f33..a78360fd6bac59a956b7a6c31305fd5fa1b19fc8 100644 (file)
@@ -499,7 +499,7 @@ sub do_git_apply ($) {
        } while (@$patches && $len < $ARG_SIZE_MAX &&
                 !oids_same_ish($patches->[0]->{oid_b}, $prv_oid_b));
 
-       my $opt = { 2 => 1, -C => $dn };
+       my $opt = { 2 => 1, -C => $dn, quiet => 1 };
        my $qsp = PublicInbox::Qspawn->new(\@cmd, $self->{git_env}, $opt);
        $self->{-cur_di} = $di;
        $self->{-qsp} = $qsp;