From b50e7754c822cb36305604408d84160adb17b700 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 15 May 2020 17:23:25 +0200 Subject: [rebootcontrol] Wait until tasks finish --- modules-available/rebootcontrol/hooks/cron.inc.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'modules-available/rebootcontrol/hooks/cron.inc.php') diff --git a/modules-available/rebootcontrol/hooks/cron.inc.php b/modules-available/rebootcontrol/hooks/cron.inc.php index 8a839767..93f2de38 100644 --- a/modules-available/rebootcontrol/hooks/cron.inc.php +++ b/modules-available/rebootcontrol/hooks/cron.inc.php @@ -82,6 +82,11 @@ function testClientToClient($srcid, $dstid) usleep(250000); $destTask = Taskmanager::status($destTask); } + // Wait for destination listener task to finish; we might want to reuse that client, + // and trying to spawn a new listener while the old one is running will fail + for ($to = 0; $to < 30 && Taskmanager::isRunning($destTask); ++$to) { + usleep(250000); + } cron_log($destTask['data']['result'][$destMachine['machineuuid']]['stdout']); // Final moment: did dest see the packets from src? Determine this by looking for the generated password if (destSawPw($destTask, $destMachine, $passwd)) @@ -108,6 +113,11 @@ function testServerToClient($dstid) $task = Taskmanager::waitComplete($task, 2000); $destTask = Taskmanager::status($destTask); } + // Wait for destination listener task to finish; we might want to reuse that client, + // and trying to spawn a new listener while the old one is running will fail + for ($to = 0; $to < 30 && Taskmanager::isRunning($destTask); ++$to) { + usleep(250000); + } cron_log($destTask['data']['result'][$destMachine['machineuuid']]['stdout']); if (destSawPw($destTask, $destMachine, $passwd)) return 1; -- cgit v1.2.3-55-g7522