Skip to content
Snippets Groups Projects
Commit 3c2baf0f authored by Mattijs Janssens's avatar Mattijs Janssens
Browse files

Replaced usleep with lockfile

parent 4b5809ea
Branches
Tags
No related merge requests found
......@@ -145,9 +145,6 @@ colourIndex=0
while :
do
# 0.5 sec
usleep 500000
for slotGroup in $WM_HOSTS
do
# split 'host:N', but catch 'host:' and 'host' too
......@@ -159,11 +156,8 @@ do
i=0
while [ "$i" -lt "$n" ]
do
lock="$host:$i"
if [ ! -f "$lockDir/$lock" ]; then
# Set lock
touch "$lockDir/$lock"
lockFile="$lockDir/$host:$i"
if lockfile -r0 "$lockFile" 2>/dev/null; then
# Set colour
colour=${colours[$colourIndex]}
#echo "** host=$host colourIndex=$colourIndex colour=$colour"
......@@ -186,7 +180,7 @@ do
retval=$?
# Release lock
rm -f "$lockDir/$lock" 2>/dev/null
rm -f "$lockFile" 2>/dev/null
exit $retval
fi
i=$(expr $i + 1)
......@@ -198,6 +192,8 @@ do
fi
done
done
# Not found any free slots. Rest a bit.
sleep 1
done
if [ "$WM_COLOURS" ]; then
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment