Skip to content

Commit

Permalink
Merge pull request #13958 from mlschroe/master
Browse files Browse the repository at this point in the history
[backend] add setchanged_unless_othersinprogress method
  • Loading branch information
mlschroe committed Mar 7, 2023
2 parents a1885f9 + 032885b commit 06343b8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/backend/BSSched/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,13 @@ sub setchanged {
BSSched::Lookat::setchanged($gctx, $changeprp, $changetype, $changelevel);
}

sub setchanged_unless_othersinprogress {
my ($ctx, $handle) = @_;
my $gctx = $ctx->{'gctx'};
die("no gctx in ctx\n") unless $gctx;
$ctx->setchanged($handle) unless $gctx->{'rctx'}->xrpc_othersinprogress($handle);
}

sub checkprojectaccess {
my ($ctx, $projid) = @_;
return BSSched::Access::checkprpaccess($ctx->{'gctx'}, $projid, $ctx->{'project'});
Expand Down
36 changes: 36 additions & 0 deletions src/backend/BSSched/RPC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ sub xrpc {
} else {
push @{$rctx->{'iswaiting_serverload_low'}->{$server}}, $handle;
}
$handle->{'_ctx'} = $ctx;
$handle->{'_iswaiting'} = $resource;
$handle->{'_server'} = $server;
$iswaiting->{$resource} = $handle;
Expand Down Expand Up @@ -177,6 +178,14 @@ sub xrpc_dowakeup {
my %did;
# do not trigger a wakeup if some other resources are still in progress
for my $rh (values(%{$rctx->{'iswaiting'}})) {
next if $rh == $handle;
if ($rh->{'_ctx'}) {
my $rctx = $rh->{'_ctx'};
my $rchangeprp = $rh->{'_changeprp'} || $rctx->{'changeprp'};
my $rchangetype = $rh->{'_changetype'} || $rctx->{'changetype'} || 'high';
my $rchangelevel = $rh->{'_changelevel'} || $rctx->{'changelevel'} || 1;
$did{"$rchangeprp/$rchangetype/$rchangelevel"} = 1 if $rchangeprp;
}
$did{$_} = 1 for keys %{$rh->{'_wakeup_have'} || {}};
}
for my $whandle (BSUtil::unify(@{$wakeup || []})) {
Expand All @@ -190,6 +199,33 @@ sub xrpc_dowakeup {
}
}

=head2 xrpc_othersinprogress - return true if this ctx needs to wait for other resources
TODO: add description
=cut

sub xrpc_othersinprogress {
my ($rctx, $handle) = @_;
my $ctx = $handle->{'_ctx'};
return 0 unless $ctx;
my $changeprp = $handle->{'_changeprp'} || $ctx->{'changeprp'};
my $changetype = $handle->{'_changetype'} || $ctx->{'changetype'} || 'high';
my $changelevel = $handle->{'_changelevel'} || $ctx->{'changelevel'} || 1;
my $did = "$changeprp/$changetype/$changelevel";
for my $rh (values(%{$rctx->{'iswaiting'}})) {
if ($rh->{'_ctx'}) {
my $rctx = $rh->{'_ctx'};
my $rchangeprp = $rh->{'_changeprp'} || $rctx->{'changeprp'};
my $rchangetype = $rh->{'_changetype'} || $rctx->{'changetype'} || 'high';
my $rchangelevel = $rh->{'_changelevel'} || $rctx->{'changelevel'} || 1;
return 1 if $rchangeprp && $did eq "$rchangeprp/$rchangetype/$rchangelevel";
}
return 1 if ($rh->{'_wakeup_have'} || {})->{$did};
}
return 0;
}

=head2 xrpc_handles - return all active handles
TODO: add description
Expand Down
4 changes: 2 additions & 2 deletions src/backend/BSSched/Remote.pm
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ sub addrepo_remote_resume {
my $gctx = $ctx->{'gctx'};
my $pool = BSSolv::pool->new();
my $r = addrepo_remote_unpackcpio($gctx, $pool, $handle->{'_prp'}, $handle->{'_arch'}, $cpio, $handle->{'_solvok'}, $handle->{'_modules'}, $error);
$ctx->setchanged($handle) unless !$r && $error && BSSched::RPC::is_transient_error($error);
$ctx->setchanged_unless_othersinprogress($handle);
}

sub import_annotation {
Expand Down Expand Up @@ -628,7 +628,7 @@ sub read_gbininfo_remote_resume {
my ($ctx, $handle, $error, $packagebinarylist) = @_;
my $gctx = $ctx->{'gctx'};
convertpackagebinarylist($gctx, $handle->{'_prpa'}, $packagebinarylist, $error, $ctx->{'prp'}, $handle->{'_isgbininfo'});
$ctx->setchanged($handle);
$ctx->setchanged_unless_othersinprogress($handle);
}

sub convertpackagebinarylist {
Expand Down

0 comments on commit 06343b8

Please sign in to comment.