Skip to content
Permalink
Browse files
mtr: fix a race condition
if a test can run in cond1,cond2 and cond1,cond3 then they can happen
to run in parallel and both wanting to create test,cond1.result~
  • Loading branch information
vuvova committed Jun 15, 2022
1 parent 2e7e89d commit f31e935
Showing 1 changed file with 6 additions and 2 deletions.
@@ -3359,17 +3359,21 @@ ($)
if ($^O eq "MSWin32") {
push @cmd, '--binary';
}
push @cmd, (qw/-r - -f -s -o/, $dest, $base_result, $resfile);
push @cmd, (qw/-r - -f -s -o/, $dest . $$, $base_result, $resfile);
if (-w $resdir) {
# don't rebuild a file if it's up to date
unless (-e $dest and -M $dest < -M $resfile
and -M $dest < -M $base_result) {
run_system(@cmd);
rename $cmd[-3], $dest or unlink $cmd[-3];
}
} else {
$cmd[-3] = $dest = $opt_tmpdir . '/' . basename($dest);
$dest = $opt_tmpdir . '/' . basename($dest);
$cmd[-3] = $dest . $$;
run_system(@cmd);
rename $cmd[-3], $dest or unlink $cmd[-3];
}

$tinfo->{result_file} = $dest;
}

0 comments on commit f31e935

Please sign in to comment.