Commit 493ce602 authored by Gary Wong's avatar Gary Wong

Fix reservation approval admission control bug.

(If the reservation being approved isn't in the list returned by LookupAll(),
presumably because it was previously pending, then append it during
feasibility checking.)
parent a3b1a555
......@@ -552,8 +552,12 @@ sub Tidy($)
sub LookupAll($$;$$)
{
my ($class, $type, $include_pending, $details) = @_;
$include_pending = 0 if( !defined( $include_pending ) );
my $cachekey = $type . ":" . $include_pending;
return $cache{$type} if( exists( $cache{$type} ) );
return $cache{$cachekey} if( exists( $cache{$cachekey} ) &&
!ref( $details ) );
# Tidy( $class );
......@@ -711,9 +715,9 @@ sub LookupAll($$;$$)
}
}
$cache{$type} = \@reservations;
$cache{$cachekey} = \@reservations;
return $cache{$type};
return $cache{$cachekey};
}
sub IsFeasible($$;$$$$$)
......
......@@ -587,6 +587,7 @@ print "$res\n" if( $debug );
while( 1 ) {
my $version = Reservation->GetVersion();
my $reservations = Reservation->LookupAll( $type );
my $found = 0;
if( defined( $modify_idx ) ) {
my $i;
......@@ -595,9 +596,16 @@ while( 1 ) {
if( defined( $r->idx() ) && $r->idx() == $modify_idx ) {
$$reservations[ $i ] = $res;
$found = 1;
last;
}
}
if( !$found ) {
# Couldn't find existing reservation in LookupAll() results:
# probably because it wasn't previously approved.
push( @$reservations, $res );
}
} else {
push( @$reservations, $res );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment