Lars Ellenberg wrote:
> BTW, looking at those ocf-shellfuncs, did anyone notice that
> ocf_take_lock is broken, because it's racy?
> Not sure if/how we should solve that, though.
ln is atomic so this ought to work:
local tmp
tmp=$(mktemp "$lockfile.XXXXXX")
echo "$$" > "$tmp"
while :
do
if ! ocf_pidfile_status "$lockfile"
then
ln "$tmp" "$lockfile" 2>/dev/null && break
fi
ocf_log info "Sleeping until $lockfile is released..."
sleep 0.$rnd
done
> possibly this could do it?
> while :; do
> pid=$(head -n1 $file)
> [ x$pid = x$$ ] && return 0 # won the race
> if [ -z "$pid" ] || ! kill -0 $pid ; then
> echo $$ > $file
> else
> # other still running
> sleep 1
> fi
> done
Looks like that would work, too.
Mike
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/