Skip to content

Commit

Permalink
[backend] local registry: lock global :repo file
Browse files Browse the repository at this point in the history
The publisher can have multiple processes publishing to a registry,
so better safe than sorry...
  • Loading branch information
mlschroe authored and coolo committed Nov 14, 2018
1 parent 39fbde6 commit 2df12b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/backend/BSPublisher/Registry.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sub ownrepo {
# make sure the directory exists
if (! -d "$registrydir/$repo") {
my $lck;
open($lck, '>>', "$registrydir/:repos");
BSUtil::lockopen($lck, '>>', "$registrydir/:repos");
mkdir_p("$registrydir/$repo");
close($lck);
}
Expand All @@ -78,7 +78,7 @@ sub ownrepo {

mkdir_p($registrydir) unless -d $registrydir;
my $lck;
open($lck, '>>', "$registrydir/:repos");
BSUtil::lockopen($lck, '>>', "$registrydir/:repos");
if (! -s "$registrydir/:repos") {
$registries = {};
} else {
Expand Down Expand Up @@ -106,7 +106,7 @@ sub disownrepo {
BSRPC::rpc($param, undef, "project=$projid", "repository=$repoid", "regrepo=$repo");

my $lck;
open($lck, '>>', "$registrydir/:repos");
BSUtil::lockopen($lck, '>>', "$registrydir/:repos");
my $registries = BSUtil::retrieve("$registrydir/:repos");
die("repository '$repo' is owned by $registries->{$repo}\n") if $registries->{$repo} && $registries->{$repo} ne $prp;
my $dir = $repo;
Expand Down

0 comments on commit 2df12b0

Please sign in to comment.