Skip to contentSkip to conversation

hotplug script: lock directory remains on error

PATCH In review Kouya Shimura 2 participants 3 messages Jun 30, 2010 – Jul 5, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hotplug script: lock directory remains on error

_release_lock should be used instead of release_lock. Adding sigerr is extra.

tools/hotplug/Linux/locking.sh +7 -1
diff -r a6d5b76abdcb tools/hotplug/Linux/locking.sh
@@ -39,6 +39,12 @@ release_lock()
 }
 
 
+# This function will be redefined in xen-hotplug-common.sh.
+sigerr() {
+  exit 1
+}
+
+
 _claim_lock()
 {
   local lockdir="$1"
@@ -47,7 +53,7 @@ _claim_lock()
 
   while [ $retries -lt $LOCK_RETRIES ]
   do
-    mkdir "$lockdir" 2>/dev/null && trap "release_lock $1; sigerr" ERR &&
+    mkdir "$lockdir" 2>/dev/null && trap "_release_lock $lockdir; sigerr" ERR &&
       _update_lock_info "$lockdir" && return
 
     local new_owner=$(_lock_owner "$lockdir")

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Kouya Shimura writes ("[Xen-devel] [PATCH] hotplug script: lock directory remains on error"):

Quoted 1 line

_release_lock should be used instead of release_lock.

That part is OK.

Quoted 1 line

Adding sigerr is extra.

I'm not sure I follow this. Why is this a good idea ? Why not just say "exit 1" in the error handler in this script ?

Ian.

#2 lore raw
Quoted 4 lines
Quoted 1 line

Adding sigerr is extra.

I'm not sure I follow this. Why is this a good idea ? Why not just say "exit 1" in the error handler in this script ?

Please see xen-hotplug-common.sh. Original (redefined) sigerr function writes some error status to the xenstore.

On the other hand, the network-bridge script also includes locking.sh. But sigerr function is not defined in it. Actually I met "sh: sigerr: command not found" message on executing the network-bridge script. Thus, I defined it in locking.sh, too.

Thanks,
Kouya

Quoted 11 lines · Ian Jackson

Kouya Shimura writes ("[Xen-devel] [PATCH] hotplug script: lock directory remains on error"):

Quoted 1 line

_release_lock should be used instead of release_lock.

That part is OK.

Quoted 1 line

Adding sigerr is extra.

I'm not sure I follow this. Why is this a good idea ? Why not just say "exit 1" in the error handler in this script ?

Ian.