aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2012-12-10 20:50:44 +0000
committerPascal Terjan <pterjan@mageia.org>2012-12-10 20:50:44 +0000
commitd623f774c90d2cb60ed6eb2a5bb5163d42d2f475 (patch)
treed8d27aa7d3d17319e8fa7f4bb4c0b1528ab7baa1
parentc24757c923841de1901501b227d1411eafefc4e4 (diff)
downloadiurt-d623f774c90d2cb60ed6eb2a5bb5163d42d2f475.tar
iurt-d623f774c90d2cb60ed6eb2a5bb5163d42d2f475.tar.gz
iurt-d623f774c90d2cb60ed6eb2a5bb5163d42d2f475.tar.bz2
iurt-d623f774c90d2cb60ed6eb2a5bb5163d42d2f475.tar.xz
iurt-d623f774c90d2cb60ed6eb2a5bb5163d42d2f475.zip
Fix concurrent access to status file
-rwxr-xr-xiurt33
1 files changed, 20 insertions, 13 deletions
diff --git a/iurt b/iurt
index 0c361fb..525c44e 100755
--- a/iurt
+++ b/iurt
@@ -621,6 +621,8 @@ my $cache = {
};
$run{cache} = $cache;
+empty_status($local_spool, \%run);
+
my (%srpm_version, @wrong_rpm, %provides, %pack_provide, $to_compile, %maint);
$to_compile = @{$run{todo}};
$to_compile += check_media(\%run, $cache, $config, \%srpm_version,
@@ -1019,14 +1021,14 @@ do {
} elsif ($pid == 0) { #child
$chroot_tmp .= "_" . int($i);
rebuild_one($dir, $srpm, $status);
- dump_status($local_spool, \%run);
+ write_status($local_spool, \%run, $srpm);
exit;
} else {
die "could not fork";
}
} else {
rebuild_one($dir, $srpm, $status);
- dump_status($local_spool, \%run);
+ write_status($local_spool, \%run, $srpm);
}
}
if ($run{parallel}) {
@@ -1073,8 +1075,6 @@ if (@wrong_rpm && open my $file, ">$local_spool/log/wrong_srpm_names.log") {
}
}
-dump_status($local_spool, \%run);
-
send_status_mail(\%run, $config, $cache) if $run{status_mail};
if ($config->{rsync_to} && !$run{no_rsync}) {
@@ -1397,17 +1397,24 @@ $user ALL=(ALL) NOPASSWD:RPM
return -f $file;
}
-sub dump_status {
+sub status_file {
my ($local_spool, $run) = @_;
my $media = $run->{media} ? "$run->{media}." : "";
- if (open my $file, ">$local_spool/log/status.${media}log") {
- foreach my $srpm (sort keys %{$run->{status}}) {
- print $file "$srpm: ";
- if ($run{status}{$srpm}) {
- print $file $run->{status}{$srpm};
- }
- print $file "\n";
- }
+ return "$local_spool/log/status.${media}log";
+}
+
+sub empty_status {
+ my ($local_spool, $run) = @_;
+ my $status_file = status_file($local_spool, $run);
+ open my $file, ">$status_file";
+}
+
+sub write_status {
+ my ($local_spool, $run, $srpm) = @_;
+ return unless $run{status}{$srpm};
+ my $status_file = status_file($local_spool, $run);
+ if (open my $file, ">>$status_file") {
+ print $file "$srpm: $run->{status}{$srpm}\n";
}
}