Skip to content

Commit

Permalink
[backend] use projid2reposerver from BSSrcServer
Browse files Browse the repository at this point in the history
Use projid2reposerver function of BSSrcServer instead of the local one.

added todo comment for the future
  • Loading branch information
lethliel committed Sep 19, 2016
1 parent ea7ed6a commit 85b1057
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/backend/BSSrcServer/Partition.pm
Expand Up @@ -25,6 +25,7 @@ use BSUtil;

sub projid2reposerver {
my ($projid) = @_;
# XXX Should not rely on local BSConfig. Should query SrcServer Config instead
return $BSConfig::reposerver unless $BSConfig::partitionservers;
my @p = @{$BSConfig::partitioning || []};
my $par;
Expand Down
21 changes: 2 additions & 19 deletions src/backend/bs_dispatch
Expand Up @@ -49,6 +49,7 @@ use BSRPC;
use BSUtil;
use BSXML;
use BSCando;
use BSSrcServer::Partition;

use strict;

Expand Down Expand Up @@ -596,24 +597,6 @@ my $lastmdloadsync;

0 if $BSConfig::partition; # skip perl warning
#
# XXX: should not be here! Use src server instead!
sub projid2reposerver {
my ($projid) = @_;
return $BSConfig::reposerver unless $BSConfig::partitionservers;
my @p = @{$BSConfig::partitioning || []};
my $par;
while (@p) {
if ($projid =~ /^$p[0]/) {
$par = $p[1];
last;
}
splice(@p, 0, 2);
}
$par = $BSConfig::partition unless defined $par;
die("cannot determine partition for $projid\n") unless defined $par;
die("partition '$par' from partitioning does not exist\n") unless $BSConfig::partitionservers->{$par};
return $BSConfig::partitionservers->{$par};
}

sub dispatchslave {
my $synced = 0;
Expand Down Expand Up @@ -650,7 +633,7 @@ sub dispatchslave {
my ($projid, $repoid, $packid) = split('::', $jn);
next unless defined $packid;
my $reposerver = $projid2repocache{$projid};
$reposerver = $projid2repocache{$projid} = projid2reposerver($projid) unless $reposerver;
$reposerver = $projid2repocache{$projid} = BSSrcServer::Partition::projid2reposerver($projid) unless $reposerver;
next if $reposerver ne $BSConfig::reposerver;
$syncedjobs{$arch}->{$job} = 1;
}
Expand Down

0 comments on commit 85b1057

Please sign in to comment.