Skip to content

Commit

Permalink
[backend] send projpack data with ymp/fileinfo_ext requests so that w…
Browse files Browse the repository at this point in the history
…e cannot deadlock
  • Loading branch information
mlschroe committed Nov 20, 2012
1 parent 69b4298 commit 1026c15
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 7 deletions.
55 changes: 48 additions & 7 deletions src/backend/bs_repserver
Expand Up @@ -955,13 +955,35 @@ sub getbinary_info {
$res->{'filename'} = $path;
$res->{'filename'} =~ s/.*\///;
if ($cgi->{'view'} && $cgi->{'view'} eq 'fileinfo_ext') {
my $bconf = getconfig($projid, $repoid, $arch);
my $projpack = BSRPC::rpc("$BSConfig::srcserver/getprojpack", $BSXML::projpack, 'withrepos', 'expandedrepos', 'withremotemap', "project=$projid", "repository=$repoid", "arch=$arch", "nopackages");
my $projpack;
my $config;
if (BSServer::have_content()) {
my $projpackxml = BSServer::read_data(10000000);
$projpack = BSUtil::fromxml($projpackxml, $BSXML::projpack, 1);
$config = '';
}
if (!$projpack) {
$projpack = BSRPC::rpc("$BSConfig::srcserver/getprojpack", $BSXML::projpack, 'withrepos', 'expandedrepos', 'withremotemap', "project=$projid", "repository=$repoid", "arch=$arch", "nopackages");
}
die("404 no such project/repository\n") unless $projpack->{'project'};
my $proj = $projpack->{'project'}->[0];
die("404 no such project\n") unless $proj && $proj->{'name'} eq $projid;
my $repo = $proj->{'repository'}->[0];
die("404 no such repository\n") unless $repo && $repo->{'name'} eq $repoid;
my $bconf;
$config = $proj->{'config'} if defined $config; # sent with the content
if ($config) {
$bconf = Build::read_config($arch, [split("\n", $config)]);
if (!$bconf->{'binarytype'}) {
$bconf->{'binarytype'} = 'rpm' if $bconf->{'type'} eq 'spec' || $bconf->{'type'} eq 'kiwi';
$bconf->{'binarytype'} = 'deb' if $bconf->{'type'} eq 'dsc';
$bconf->{'binarytype'} = 'arch' if $bconf->{'type'} eq 'arch';
$bconf->{'binarytype'} ||= 'UNKNWON';
}
} else {
$bconf = getconfig($projid, $repoid, $arch);
}

my %remotemap = map {$_->{'project'} => $_} @{$projpack->{'remotemap'} || []};
my @prp = map {"$_->{'project'}/$_->{'repository'}"} @{$repo->{'path'} || []};
my $pool = BSSolv::pool->new();
Expand Down Expand Up @@ -3118,7 +3140,12 @@ sub publisheddir {
last if $binary;
}
$binary ||= "$extrep/$binaryname";
return makeymp($projid, $repoid, $binary);
my $projpack;
if (BSServer::have_content()) {
my $projpackxml = BSServer::read_data(10000000);
$projpack = BSUtil::fromxml($projpackxml, $BSXML::projpack, 1);
}
return makeymp($projid, $repoid, $binary, $projpack);
}
@res = ls("$extrep/$arch");
}
Expand All @@ -3128,7 +3155,7 @@ sub publisheddir {
}

sub makeymp {
my ($projid, $repoid, $binary) = @_;
my ($projid, $repoid, $binary, $projpackin) = @_;

my $binaryname;
my $data;
Expand All @@ -3145,17 +3172,26 @@ sub makeymp {
}
$data = Build::query($binary, 'description' => 1);
#die("no such binary\n") unless $data;
my $projpack = BSRPC::rpc("$BSConfig::srcserver/getprojpack", $BSXML::projpack, 'withrepos', 'expandedrepos', 'nopackages', "project=$projid", "repository=$repoid");
my $projpack;
if ($projpackin && $projpackin->{'project'}->[0]->{'name'} eq $projid) {
$projpack = $projpackin;
} else {
$projpack = BSRPC::rpc("$BSConfig::srcserver/getprojpack", $BSXML::projpack, 'withrepos', 'expandedrepos', 'nopackages', "project=$projid", "repository=$repoid");
}
my $proj = $projpack->{'project'}->[0];
die("no such project\n") unless $proj && $proj->{'name'} eq $projid;
my $repo = $proj->{'repository'}->[0];
die("no such repository\n") unless $repo && $repo->{'name'} eq $repoid;
my @nprojids = grep {$_ ne $projid} map {$_->{'project'}} @{$repo->{'path'} || []};
my %nprojpack;
if ($projpackin) {
$nprojpack{$_->{'name'}} ||= $_ for @{$projpackin->{'project'} || []};
}
@nprojids = grep {!$nprojpack{$_}} @nprojids;
if (@nprojids) {
my @args = map {"project=$_"} @nprojids;
my $nprojpack = BSRPC::rpc("$BSConfig::srcserver/getprojpack", $BSXML::projpack, 'nopackages', @args);
%nprojpack = map {$_->{'name'} => $_} @{$nprojpack->{'project'} || []};
$nprojpack{$_->{'name'}} ||= $_ for @{$nprojpack->{'project'} || []};
}
my $ymp = {};
$ymp->{'xmlns:os'} = 'http://opensuse.org/Standards/One_Click_Install';
Expand Down Expand Up @@ -3254,7 +3290,12 @@ sub publishedfile {
return publisheddir($cgi, $projid, $repoid, "$arch/$filename");
}
if ($cgi->{'view'} && $cgi->{'view'} eq 'ymp') {
return makeymp($projid, $repoid, "$extrep/$filename");
my $projpack;
if (BSServer::have_content()) {
my $projpackxml = BSServer::read_data(10000000);
$projpack = BSUtil::fromxml($projpackxml, $BSXML::projpack, 1);
}
return makeymp($projid, $repoid, "$extrep/$filename", $projpack);
}
die("no such file\n") unless -f "$extrep/$filename";
if ($cgi->{'view'} && $cgi->{'view'} eq 'fileinfo') {
Expand Down
38 changes: 38 additions & 0 deletions src/backend/bs_srcserver
Expand Up @@ -5386,6 +5386,18 @@ sub getbinary {
'ignorestatus' => 1,
'receiver' => \&BSServer::reply_receiver,
};
if ($view && $view eq 'fileinfo_ext') {
my $projpack = (getprojpack({'nopackages' => 1, 'withrepos' => 1, 'expandedrepos' => 1, 'withremotemap' => 1, 'withconfig' => 1}, [ $projid ], [ $repoid ], undef, $arch))[0];
if ($projpack) {
if ($projpack->{'project'} && $projpack->{'project'}->[0]->{'name'} eq $projid) {
my $config = (getbuildconfig({}, $projid, $repoid))[0];
$projpack->{'project'}->[0]->{'config'} = $config if $config;
}
$param->{'request'} = 'POST';
$param->{'data'} = BSUtil::toxml($projpack, $BSXML::projpack);
$param->{'headers'} = [ 'Content-Type: application/octet-stream' ];
}
}
if ($proj->{'remoteurl'}) {
$param->{'uri'} = "$proj->{'remoteurl'}/build/$proj->{'remoteproject'}/$repoid/$arch/$packid/$filename";
$param->{'proxy'} = $proxy;
Expand Down Expand Up @@ -5965,7 +5977,28 @@ sub listservices {
sub published {
my ($cgi, $projid, $repoid, $arch, $filename, $subfilename) = @_;
my @args;
my $projpack;
die("unknown view '$cgi->{'view'}'\n") if $cgi->{'view'} && $cgi->{'view'} ne 'ymp' && $cgi->{'view'} ne 'fileinfo';
if (defined($projid) && defined($repoid) && $cgi->{'view'} && $cgi->{'view'} eq 'ymp') {
# attach projpack data so that the repo server does not need to
# reconnect us
$projpack = (getprojpack({'nopackages' => 1, 'withrepos' => 1, 'expandedrepos' => 1}, [ $projid ], [ $repoid ], undef, 'noarch'))[0];
my $proj = $projpack->{'project'}->[0];
die("no such project\n") unless $proj && $proj->{'name'} eq $projid;
my $repo = $proj->{'repository'}->[0];
die("no such repository\n") unless $repo && $repo->{'name'} eq $repoid;
$projpack->{'project'} = [ $proj ];
my @nprojids = grep {$_ ne $projid} map {$_->{'project'}} @{$repo->{'path'} || []};
@nprojids = unify(@nprojids);
for my $nprojid (@nprojids) {
my $nproj = (getproject({}, $nprojid))[0];
push @{$projpack->{'project'}}, {
'name' => $nprojid,
'title' => $nproj->{'title'} || '',
'description' => $nproj->{'description'} || '',
};
}
}
push @args, "view=$cgi->{'view'}" if $cgi->{'view'};
my $p = "/published";
$p .= "/$projid" if defined $projid;
Expand All @@ -5978,6 +6011,11 @@ sub published {
'ignorestatus' => 1,
'receiver' => \&BSServer::reply_receiver,
};
if ($projpack) {
$param->{'request'} = 'POST';
$param->{'data'} = BSUtil::toxml($projpack, $BSXML::projpack);
$param->{'headers'} = [ 'Content-Type: application/octet-stream' ];
}
BSWatcher::rpc($param, undef, @args);
return undef;
}
Expand Down

0 comments on commit 1026c15

Please sign in to comment.