From: yang.zhang Date: Tue, 23 May 2017 10:01:04 +0000 (+0800) Subject: Add lock for multi spec export X-Git-Tag: submit/devel/20190730.074511~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c6972bb5cff99ba21291a185a5a6f2bfabb5ec75;p=tools%2Fdepanneur.git Add lock for multi spec export Change-Id: I63d6123432bf46730e36ac1ba2212cbb36de6e71 Signed-off-by: Jun Wang --- diff --git a/depanneur b/depanneur index 33717da..153cba2 100755 --- a/depanneur +++ b/depanneur @@ -43,6 +43,10 @@ my $DETACHING:shared; # Flag to inform main thread update pkgdeps my $dirty:shared=0; +my %export_packs:shared = (); +my $export_lock:shared; +my $SINGLE_SPEC = 1; +my $MULTI_SPEC = 2; # Set the variable $File::Find::dont_use_nlink if you're using AFS, # since AFS cheats. @@ -757,8 +761,17 @@ sub read_cache { sub write_cache { my ($cache_key, $cache_val, $base, $spec, $packaging_dir, $upstream_branch, $upstream_tag) = @_; my $cache_fname = "$cache_path/$cache_key"; - my @export_out = gbs_export($base, $spec, $packaging_dir, $upstream_branch, $upstream_tag); - + my @export_out; + my $n = $export_packs{$base}; + if ($n ne $SINGLE_SPEC) { + info("multi spec export in order:$base\t$spec"); + { + lock($export_lock); + @export_out = gbs_export($base, $spec, $packaging_dir, $upstream_branch, $upstream_tag); + } + } else { + @export_out = gbs_export($base, $spec, $packaging_dir, $upstream_branch, $upstream_tag); + } if (shift @export_out) { # if export failed, collect export error to report push(@export_errors, {package_name => $cache_key, @@ -2348,9 +2361,21 @@ if ($style eq 'git') { } else { info("package $name not support skip export source"); $data_queue->enqueue($pack); + my $lock_name = $pack->{"project_base_path"}; + if (exists $export_packs{$lock_name}) { + $export_packs{$lock_name} = $MULTI_SPEC; + } else { + $export_packs{$lock_name} = $SINGLE_SPEC; + } } } else { $data_queue->enqueue($pack); + my $lock_name = $pack->{"project_base_path"}; + if (exists $export_packs{$lock_name}) { + $export_packs{$lock_name} = $MULTI_SPEC; + } else { + $export_packs{$lock_name} = $SINGLE_SPEC; + } } }