From 3bbd79c61f670919e3fd870e4c89547f6a20fe5f Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Mon, 25 Jan 2016 13:14:51 +0100 Subject: [PATCH] [backend] put running projpack xrpcs into fetchprojpacks when writing the state We don't want to lose the events! --- src/backend/BSSched/EventHandler.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/backend/BSSched/EventHandler.pm b/src/backend/BSSched/EventHandler.pm index ce1428067f6..cbc3cf2a439 100644 --- a/src/backend/BSSched/EventHandler.pm +++ b/src/backend/BSSched/EventHandler.pm @@ -473,6 +473,33 @@ sub event_exit { $schedstate->{'delayedfetchprojpacks'} = $gctx->{'delayedfetchprojpacks'}; $schedstate->{'watchremote_start'} = $gctx->{'watchremote_start'}; $schedstate->{'fetchprojpacks'} = $ectx->{'fetchprojpacks'} if %{$ectx->{'fetchprojpacks'} || {}}; + # collect all running async projpack requests + for my $handle ($gctx->{'rctx'}->xrpc_handles()) { + my $projid = $handle->{'_iswaiting'}; + next if $projid =~ /\//; + my %packids; + my $good; + my $meta; + for my $h ($handle, @{$handle->{'_nextxrpc'} || []}) { + my $async = $h; + # HACK: 2 is $param + $async = $h->{'_xrpc_data'}->[2]->{'async'} if $h->{'_xrpc_data'}; + next if $async->{'_projid'} ne $projid; + $good = 1; + if ($async->{'_packids'}) { + $packids{$_} = 1 for @{$async->{'_packids'}}; + } else { + $packids{$_} = 1 for @{$async->{'_lpackids'} || []}; + $meta = 1; + } + } + next unless $good; + my @packids = sort keys %packids; + push @packids, undef if $meta || !@packids; + $schedstate->{'fetchprojpacks'} ||= {}; + $schedstate->{'fetchprojpacks'}->{$projid} = [ @{$schedstate->{'fetchprojpacks'}->{$projid} || []}, @packids ]; + } + my $rundir = $gctx->{'rundir'}; unlink("$rundir/bs_sched.$myarch.state"); my $statefile = "$rundir/bs_sched.$myarch.state";