]> xenbits.xensource.com Git - osstest.git/commitdiff
plan_search: Break out $share_compat_ok
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 8 Nov 2017 16:16:29 +0000 (16:16 +0000)
committerIan Jackson <iwj@xenproject.org>
Fri, 2 Oct 2020 15:49:13 +0000 (16:49 +0100)
No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Osstest/Executive.pm

index 4cd4aa505e9c580ba5a2507f7237f4e02a5a3d9e..e4bb0868f1b5c0fdb77a327b605faacf8ded0046 100644 (file)
@@ -700,6 +700,20 @@ sub plan_search ($$$$) {
             # this period is entirely after the proposed slot;
             # so no need to check this or any later periods
 
+           my $share_compat_ok = sub {
+               my ($eshare) = @_;
+               return 0 unless defined $req->{Shared};
+               return 0 unless $req->{Shared} eq $eshare->{Type};
+               if (defined $share_wear) {
+                   $share_wear++ if $startevt->{Type} eq 'Start';
+               } else {
+                   $share_wear= $eshare->{Wear}+1;
+               }
+               return 0 if $share_wear > $req->{SharedMaxWear};
+               return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
+               return 1;
+           };
+
            next PERIOD if $endevt->{Time} <= $try_time;
             # this period is entirely before the proposed slot;
             # it doesn't overlap, but must check subsequent periods
@@ -711,15 +725,7 @@ sub plan_search ($$$$) {
                my $eshare= $startevt->{Share};
                if ($eshare) {
                    $dbgprint->("PLAN LOOP   OVERLAP ESHARE");
-                   last CHECK unless defined $req->{Shared};
-                   last CHECK unless $req->{Shared} eq $eshare->{Type};
-                   if (defined $share_wear) {
-                       $share_wear++ if $startevt->{Type} eq 'Start';
-                   } else {
-                       $share_wear= $eshare->{Wear}+1;
-                   }
-                   last CHECK if $share_wear > $req->{SharedMaxWear};
-                   last CHECK if $eshare->{Shares} != $req->{SharedMaxTasks};
+                   last CHECK unless $share_compat_ok->($eshare);
                }
                # We have suitable availability for this period
                $dbgprint->("PLAN LOOP   OVERLAP AVAIL OK");