Search
j0ke.net Open Build Service
>
Projects
>
virtualization
:
xen
:
redhat
:
3.4.0
>
xen
> xen-3.4.0-hotplug-locking-rhel.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File xen-3.4.0-hotplug-locking-rhel.patch of Package xen
--- xen-3.4.0.orig/tools/hotplug/Linux/locking.sh 2009-05-18 13:05:38.000000000 +0200 +++ xen-3.4.0/tools/hotplug/Linux/locking.sh 2009-05-23 14:39:07.000000000 +0200 @@ -1,5 +1,6 @@ # # Copyright (c) 2005 XenSource Ltd. +# Copyright (c) 2007 Red Hat # # This library is free software; you can redistribute it and/or # modify it under the terms of version 2.1 of the GNU Lesser General Public @@ -19,80 +20,30 @@ # Serialisation # -LOCK_SLEEPTIME=1 -LOCK_SPINNING_RETRIES=5 -LOCK_RETRIES=100 LOCK_BASEDIR=/var/run/xen-hotplug - -claim_lock() -{ - local lockdir="$LOCK_BASEDIR/$1" - mkdir -p "$LOCK_BASEDIR" - _claim_lock "$lockdir" -} - - -release_lock() -{ - _release_lock "$LOCK_BASEDIR/$1" -} - - -_claim_lock() +_setlockfd() { - local lockdir="$1" - local owner=$(_lock_owner "$lockdir") - local retries=0 - - while [ $retries -lt $LOCK_RETRIES ] - do - mkdir "$lockdir" 2>/dev/null && trap "release_lock $1; sigerr" ERR && - _update_lock_info "$lockdir" && return - - local new_owner=$(_lock_owner "$lockdir") - if [ "$new_owner" != "$owner" ] - then - owner="$new_owner" - retries=0 - fi - - if [ $retries -gt $LOCK_SPINNING_RETRIES ] - then - sleep $LOCK_SLEEPTIME - else - sleep 0 - fi - retries=$(($retries + 1)) - done - _steal_lock "$lockdir" + local i + for ((i = 0; i < ${#_lockdict}; i++)) + do [ -z "${_lockdict[$i]}" -o "${_lockdict[$i]}" = "$1" ] && break + done + _lockdict[$i]="$1" + let _lockfd=200+i } -_release_lock() -{ - trap sigerr ERR - rm -rf "$1" 2>/dev/null || true -} - - -_steal_lock() -{ - local lockdir="$1" - local owner=$(cat "$lockdir/owner" 2>/dev/null || echo "unknown") - log err "Forced to steal lock on $lockdir from $owner!" - _release_lock "$lockdir" - _claim_lock "$lockdir" -} - - -_lock_owner() +claim_lock() { - cat "$1/owner" 2>/dev/null || echo "unknown" + mkdir -p "$LOCK_BASEDIR" + _setlockfd $1 + eval "exec $_lockfd>>$LOCK_BASEDIR/$1" + flock -x $_lockfd } -_update_lock_info() +release_lock() { - echo "$$: $0" >"$1/owner" + _setlockfd $1 + flock -u $_lockfd }