From b5a260e77d0206ea8eb35216f211c393015c6f89 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Tue, 3 Aug 2010 20:23:00 +0300 Subject: [PATCH] ControlScripts: add support for infinite time in (t1, t2) periods when scheduling clients; if that is the case there is no enforced time-based end to a client --- ControlScripts/schedule_client.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ControlScripts/schedule_client.sh b/ControlScripts/schedule_client.sh index 795e40e..ebb232b 100755 --- a/ControlScripts/schedule_client.sh +++ b/ControlScripts/schedule_client.sh @@ -65,6 +65,17 @@ resume_client() kill -CONT ${client_pid} } +# test whether time in period (t1, t2) is infinte ("-" sign) +# if that is the case, sleep indefinitely, waiting for shut down +test_infinte() +{ + time="$1" + + if test "$time" = "-"; then + sleep 1000d + fi +} + parse_periods DEBUG echo "start_time is ${start_time}" @@ -79,6 +90,8 @@ DEBUG echo "background_pid is ${background_pid}" old_time=${start_time} for ((i = 0; i < ${#suspend_resume[@]}; i += 2)); do + test_infinite ${suspend_resume[$i]} + to_sleep=$((${suspend_resume[$i]} - ${old_time})) sleep ${to_sleep} client_pid=$(pgrep -P ${background_pid}) @@ -86,12 +99,16 @@ for ((i = 0; i < ${#suspend_resume[@]}; i += 2)); do suspend_client ${client_pid} old_time=${suspend_resume[$i]} + test_infinite ${suspend_resume[$(($i+1))]} + to_sleep=$((${suspend_resume[$(($i+1))]} - ${old_time})) sleep ${to_sleep} resume_client ${client_pid} old_time=${suspend_resume[$(($i+1))]} done +test_infinite ${stop_time} + to_sleep=$((${stop_time} - ${old_time})) sleep ${to_sleep} stop_client ${client_type} -- 2.20.1