[tools] testbot/Engine: Prevent recursion into ScheduleJobs().

Francois Gouget fgouget at codeweavers.com
Fri Jun 17 03:09:27 CDT 2022


Recursion may happen through the ScheduleJobs() -> VM::Run() ->
VMStatusChange() -> ScheduleJobs() chain.
It can cause multiple revert processes to run on the same VM, or even a
revert process to run at the same time as a task.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
This issue is caused by the patch to process notifications originating
from the Engine (9b0894ed386f). What's strange is I'm not seeing this
issue in my test environment.
---
 testbot/lib/WineTestBot/Engine/Scheduler.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/testbot/lib/WineTestBot/Engine/Scheduler.pm b/testbot/lib/WineTestBot/Engine/Scheduler.pm
index b9304c1c8f..bba7e6a2cc 100644
--- a/testbot/lib/WineTestBot/Engine/Scheduler.pm
+++ b/testbot/lib/WineTestBot/Engine/Scheduler.pm
@@ -946,6 +946,7 @@ sub _PowerOffDirtyVMs($)
   }
 }
 
+my $_InScheduleJobs;
 my $_LastTaskCounts = "";
 
 =pod
@@ -1004,6 +1005,11 @@ kept on standby so they are ready when their turn comes.
 
 sub ScheduleJobs()
 {
+  # Don't let Engine notifications (specifically VMStatusChange) cause
+  # recursion into ScheduleJobs().
+  return if ($_InScheduleJobs);
+  $_InScheduleJobs = 1;
+
   my $Sched = _CheckAndClassifyVMs();
   my $NeededVMs = _ScheduleTasks($Sched);
   _RevertVMs($Sched, $NeededVMs);
@@ -1053,6 +1059,8 @@ sub ScheduleJobs()
     $Timeout = 600;
   }
   AddEvent("ScheduleJobs", $Timeout, 0, \&ScheduleJobs);
+
+  $_InScheduleJobs = undef;
 }
 
 
-- 
2.30.2



More information about the wine-devel mailing list