Occasionally, there may be different resources of the same type in a
cluster configuration that should not execute actions in
parallel. When a resource agent needs to guard against parallel
execution on the same machine, it can use the ocf_take_lock and
ocf_release_lock_on_exit convenience functions:
LOCKFILE=${HA_RSCTMP}/foobar
ocf_release_lock_on_exit $LOCKFILE
foobar_start() {
...
ocf_take_lock $LOCKFILE
...
}ocf_take_lock attempts to acquire the designated $LOCKFILE. When
it is unavailable, it sleeps a random amount of time between 0 and 1
seconds, and retries. ocf_release_lock_on_exit releases the lock
file when the agent exits (for any reason).