* [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone
@ 2010-12-14 8:38 Kouya Shimura
2010-12-14 17:16 ` Ian Jackson
0 siblings, 1 reply; 4+ messages in thread
From: Kouya Shimura @ 2010-12-14 8:38 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 199 bytes --]
When a script using locking.sh is stopped by ctrl-C, the lock file remains.
We have to wait 100 seconds for releasing the lock at the next time.
Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
[-- Attachment #2: locking.sh.patch --]
[-- Type: text/x-patch, Size: 483 bytes --]
diff -r 89116f28083f tools/hotplug/Linux/locking.sh
--- a/tools/hotplug/Linux/locking.sh Wed Dec 08 10:46:31 2010 +0000
+++ b/tools/hotplug/Linux/locking.sh Mon Dec 13 10:36:25 2010 +0900
@@ -61,6 +61,12 @@ _claim_lock()
then
owner="$new_owner"
retries=0
+ else
+ local pid=$(echo $owner | cut -d : -f 1)
+ if [ ! -f "/proc/$pid/status" ]
+ then
+ _release_lock $lockdir
+ fi
fi
if [ $retries -gt $LOCK_SPINNING_RETRIES ]
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone
2010-12-14 8:38 [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone Kouya Shimura
@ 2010-12-14 17:16 ` Ian Jackson
2010-12-15 4:26 ` Kouya Shimura
0 siblings, 1 reply; 4+ messages in thread
From: Ian Jackson @ 2010-12-14 17:16 UTC (permalink / raw)
To: Kouya Shimura; +Cc: xen-devel
Kouya Shimura writes ("[Xen-devel] [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone"):
> When a script using locking.sh is stopped by ctrl-C, the lock file remains.
> We have to wait 100 seconds for releasing the lock at the next time.
Thanks, I have applied your patch.
This kind of thing is one reason why lockfiles where the lock is
regarded as held if the file exists are horrible. It's a shame that
we don't have any fcntl/flock style locking primitives available in
shell.
Ian.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone
2010-12-14 17:16 ` Ian Jackson
@ 2010-12-15 4:26 ` Kouya Shimura
2010-12-15 16:49 ` Ian Jackson
0 siblings, 1 reply; 4+ messages in thread
From: Kouya Shimura @ 2010-12-15 4:26 UTC (permalink / raw)
To: Ian Jackson; +Cc: xen-devel
[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 802 bytes --]
Sorry, the patch was unsafe for mutual exclusion. Please apply this too.
Since there is a case that the owner file doesn't exist yet
when an atomic mkdir operation fails.
Thanks,
Kouya
Ian Jackson writes:
> Kouya Shimura writes ("[Xen-devel] [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone"):
> > When a script using locking.sh is stopped by ctrl-C, the lock file remains.
> > We have to wait 100 seconds for releasing the lock at the next time.
>
> Thanks, I have applied your patch.
>
> This kind of thing is one reason why lockfiles where the lock is
> regarded as held if the file exists are horrible. It's a shame that
> we don't have any fcntl/flock style locking primitives available in
> shell.
>
> Ian.
Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
[-- Attachment #2: locking.sh2.patch --]
[-- Type: text/x-patch, Size: 463 bytes --]
diff -r 197c0b40423a tools/hotplug/Linux/locking.sh
--- a/tools/hotplug/Linux/locking.sh Tue Dec 14 19:28:25 2010 +0000
+++ b/tools/hotplug/Linux/locking.sh Wed Dec 15 11:56:04 2010 +0900
@@ -63,7 +63,7 @@ _claim_lock()
retries=0
else
local pid=$(echo $owner | cut -d : -f 1)
- if [ ! -f "/proc/$pid/status" ]
+ if [ -n "$pid" -a "$pid" != "unknown" -a ! -f "/proc/$pid/status" ]
then
_release_lock $lockdir
fi
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone
2010-12-15 4:26 ` Kouya Shimura
@ 2010-12-15 16:49 ` Ian Jackson
0 siblings, 0 replies; 4+ messages in thread
From: Ian Jackson @ 2010-12-15 16:49 UTC (permalink / raw)
To: Kouya Shimura; +Cc: xen-devel
Kouya Shimura writes ("Re: [Xen-devel] [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone"):
> Sorry, the patch was unsafe for mutual exclusion. Please apply this too.
> Since there is a case that the owner file doesn't exist yet
> when an atomic mkdir operation fails.
Applied, thanks.
Ian.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-15 16:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-14 8:38 [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone Kouya Shimura
2010-12-14 17:16 ` Ian Jackson
2010-12-15 4:26 ` Kouya Shimura
2010-12-15 16:49 ` Ian Jackson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.