From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kouya Shimura Subject: Re: [PATCH] tools/hotplug/Linux: forced to release lock if holder process is gone Date: Wed, 15 Dec 2010 13:26:56 +0900 Message-ID: <7k7hfbwti5.fsf@jp.fujitsu.com> References: <7kk4jchhpw.fsf@jp.fujitsu.com> <19719.42613.402719.207790@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ri8egEDxDp" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <19719.42613.402719.207790@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --ri8egEDxDp Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit 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 --ri8egEDxDp Content-Type: text/x-patch Content-Disposition: inline; filename="locking.sh2.patch" Content-Transfer-Encoding: 7bit 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 --ri8egEDxDp Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --ri8egEDxDp--