Updated Branches:
  refs/heads/master d81f7156d -> 7602997b9

CLOUDSTACK-1522: Add timestamp to lock

Use higher precision timestamp rather than file timestamp to find out the order
of lock requester


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/dd721a83
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/dd721a83
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/dd721a83

Branch: refs/heads/master
Commit: dd721a832a408385d126975d7ab7d76b03ad8414
Parents: d81f715
Author: Sheng Yang <[email protected]>
Authored: Tue Mar 5 14:22:15 2013 -0800
Committer: Sheng Yang <[email protected]>
Committed: Tue Mar 5 15:58:57 2013 -0800

----------------------------------------------------------------------
 patches/systemvm/debian/config/root/func.sh |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dd721a83/patches/systemvm/debian/config/root/func.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/func.sh 
b/patches/systemvm/debian/config/root/func.sh
index 86317a0..8cc9608 100644
--- a/patches/systemvm/debian/config/root/func.sh
+++ b/patches/systemvm/debian/config/root/func.sh
@@ -23,7 +23,8 @@
 # $2 timeout seconds
 getLockFile() {
     __locked=0
-    __LOCKFILE="/tmp/$1-$$.lock"
+    __TS=`date +%s%N`
+    __LOCKFILE="/tmp/$__TS-$$-$1.lock"
     if [ $2 ]
     then
         __TIMEOUT=$2
@@ -49,7 +50,7 @@ getLockFile() {
     
     for i in `seq 1 $(($__TIMEOUT * 10))`
     do
-        currlock=`ls -tr /tmp/$1-*.lock | head -n1`
+        currlock=`ls /tmp/*-$1.lock | head -n1`
         if [ $currlock -ef $__LOCKFILE ]
         then
             __locked=1
@@ -77,7 +78,7 @@ getLockFile() {
 # $1 lock filename
 # $2 locked(1) or not(0)
 releaseLockFile() {
-    __LOCKFILE="/tmp/$1-$$.lock"
+    __LOCKFILE="/tmp/*-$$-$1.lock"
     __locked=$2
     if [ "$__locked" == "1" ]
     then

Reply via email to