What matters for the purpose of $share_reuse is not whether the host
is actually being _shared_ (ie, there are other concurrent allocations
and therefore a concurrent Event with Share information). What we
really want to know is whether the *last* use of this host was a
suitable sharing setup - because we actually want to know if we will
be able to skip our setup.
So track that explicitly. (The slightly odd structure, where there
are two loops in one, means that we reset $last_eshare when we go onto
the next $req ie the next host to check.)
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
my $try_time= 0;
my $confirmedok= 0;
my $share_reuse= 0;
+ my $last_eshare;
for (;;) {
my $req= $requestlist->[$reqix];
# this period is entirely after the proposed slot;
# so no need to check this or any later periods
+ $last_eshare = $startevt->{
+ $startevt->{Type} eq 'Unshare' ? 'PreviousShare' : 'Share'
+ };
+
next PERIOD if $endevt->{Time} <= $try_time;
# this period is entirely before the proposed slot;
# it doesn't overlap, but must check subsequent periods
" try=$try_time confirmed=$confirmedok reuse=$share_reuse");
$confirmedok++;
- $share_reuse++ if defined $share_wear;
+ $share_reuse++ if $last_eshare and $share_compat_ok->($last_eshare);
$reqix++;
$reqix %= @$requestlist;
+ undef $last_eshare;
last if $confirmedok==@$requestlist;
}