Skip to content
Snippets Groups Projects
Commit a808c674 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

optimize _wait_for_free_slot

parent cb1127c6
No related branches found
No related tags found
1 merge request!28optimize _wait_for_free_slot
......@@ -354,6 +354,10 @@ function _update(){
# "neverending" loop that waits until the current process is
# the one with lowest PID
function _wait_for_free_slot(){
if [ "$FREESLOT" = "1" ]; then
_debuglog "skip _wait_for_free_slot"
return 0
fi
local _bWait=true
_debuglog "start in _wait_for_free_slot"
typeset -i local _iFirstPID=0
......@@ -363,10 +367,10 @@ function _wait_for_free_slot(){
_wd "--- Need to wait until own process PID $$ is on top ... "
while [ $_bWait = true ];
do
_sProcesses=$( ps -ef | grep "bash.*$0" | grep -v "ssh.*@" | grep -v "grep" | sort -k 2 -n )
_sProcesses=$( ps aux | grep "bash.*$0" | grep -v "ssh.*@" | grep -v "grep" | sort -k 2 -n )
_iPos=$( echo "$_sProcesses" | grep -n " $$ " | head -1 | cut -f 1 -d ':' )
_wd "instances: $_iProcesses"
_wd "process $$ is on position $_iPos"
test ${CM_showdebug} -ne 0 && echo "$_sProcesses"
# if [ $_iFirstPID -eq $$ ]; then
......@@ -381,6 +385,7 @@ function _wait_for_free_slot(){
sleep $((3 + RANDOM % 3));
fi
done
FREESLOT=1
_debuglog "end _wait_for_free_slot"
}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment