Skip to content
Snippets Groups Projects

optimize _wait_for_free_slot

Merged Hahn Axel (hahn) requested to merge add-http-challenge into master
2 files
+ 970
2
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 7
2
@@ -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"
}
Loading