summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-05-15 17:23:25 +0200
committerSimon Rettberg2020-05-15 17:29:08 +0200
commitb50e7754c822cb36305604408d84160adb17b700 (patch)
tree7904505e2ac08290f7696adbd961f3f558546be0
parent[rebootcontrol] Cleanup, TODO (diff)
downloadslx-admin-b50e7754c822cb36305604408d84160adb17b700.tar.gz
slx-admin-b50e7754c822cb36305604408d84160adb17b700.tar.xz
slx-admin-b50e7754c822cb36305604408d84160adb17b700.zip
[rebootcontrol] Wait until tasks finish
-rw-r--r--modules-available/rebootcontrol/hooks/cron.inc.php10
1 files changed, 10 insertions, 0 deletions
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;