Lock paths in the scm cache

This is necessary now that hydra-evaluator runs multiple evaluations
in parallel, to prevent corruption of Git/Mercurial clones.
This commit is contained in:
Eelco Dolstra
2017-02-21 18:11:53 +01:00
parent 52753e49c2
commit 9f6afb3375
2 changed files with 22 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ use Digest::SHA qw(sha256_hex);
use File::Path;
use Hydra::Helper::Nix;
use Nix::Store;
use Fcntl qw(:flock);
sub supportedInputTypes {
my ($self, $inputTypes) = @_;
@@ -40,6 +41,9 @@ sub fetchInput {
my $clonePath = _clonePath($uri);
open(my $lock, ">", "$clonePath.lock") or die;
flock($lock, LOCK_EX) or die;
if (! -d $clonePath) {
(my $res, $stdout, $stderr) = captureStdoutStderr(600,
"hg", "clone", $uri, $clonePath);