Fixed bogus WAIT_FOR_TASK_COMPLETION_ return from ExecTasks

This commit is contained in:
deajan 2018-10-15 19:23:48 +02:00
parent efd8dca58e
commit 569048c19b
2 changed files with 7 additions and 3 deletions

View File

@ -1933,6 +1933,7 @@ function Sync {
IFS=';' read -r -a pidArray <<< "$(eval echo \"\$WAIT_FOR_TASK_COMPLETION_${FUNCNAME[0]}_deletionPropagation\")" IFS=';' read -r -a pidArray <<< "$(eval echo \"\$WAIT_FOR_TASK_COMPLETION_${FUNCNAME[0]}_deletionPropagation\")"
initiatorFail=false initiatorFail=false
targetFail=false targetFail=false
echo "--${pidArray[@]}--" #WIP
for pid in "${pidArray[@]}"; do for pid in "${pidArray[@]}"; do
pid=${pid%:*} pid=${pid%:*}
if [ "$pid" == "$initiatorPid" ]; then if [ "$pid" == "$initiatorPid" ]; then

View File

@ -938,6 +938,7 @@ function ExecTasks {
local hasPids=false # Are any valable pids given to function ? #__WITH_PARANOIA_DEBUG local hasPids=false # Are any valable pids given to function ? #__WITH_PARANOIA_DEBUG
local functionMode local functionMode
local softAlert=false local softAlert=false
local failedPidsList # List containing failed pids with exit code separated by semicolons (eg : 2355:1;4534:2;2354:3)
# Initialise global variable # Initialise global variable
eval "WAIT_FOR_TASK_COMPLETION_$id=\"\"" eval "WAIT_FOR_TASK_COMPLETION_$id=\"\""
@ -1105,10 +1106,10 @@ function ExecTasks {
fi fi
errorcount=$((errorcount+1)) errorcount=$((errorcount+1))
# Welcome to variable variable bash hell # Welcome to variable variable bash hell
if [ "$(eval echo \"\$WAIT_FOR_TASK_COMPLETION_$id\")" == "" ]; then if [ "$failedPidsList" == "" ]; then
eval "WAIT_FOR_TASK_COMPLETION_$id=\"$pid:$retval\"" failedPidsList="$pid:$retval"
else else
eval "WAIT_FOR_TASK_COMPLETION_$id=\"$WAIT_FOR_TASK_COMPLETION_$id;$pid:$retval\"" failedPidsList="$failedPidsList;$pid:$retval"
fi fi
else else
Logger "${FUNCNAME[0]} called by [$id] finished monitoring pid [$pid] with exitcode [$retval]." "DEBUG" Logger "${FUNCNAME[0]} called by [$id] finished monitoring pid [$pid] with exitcode [$retval]." "DEBUG"
@ -1270,6 +1271,8 @@ function ExecTasks {
# Return exit code if only one process was monitored, else return number of errors # Return exit code if only one process was monitored, else return number of errors
# As we cannot return multiple values, a global variable WAIT_FOR_TASK_COMPLETION contains all pids with their return value # As we cannot return multiple values, a global variable WAIT_FOR_TASK_COMPLETION contains all pids with their return value
eval "WAIT_FOR_TASK_COMPLETION_$id=\"$failedPidsList\""
if [ $mainItemCount -eq 1 ]; then if [ $mainItemCount -eq 1 ]; then
return $retval return $retval
else else