On Jan 29, 2008 12:48 PM, Richard Hughes <[EMAIL PROTECTED]> wrote:
>
> On Tue, 2008-01-29 at 21:23 +0100, Till Maas wrote:
> > On Tue January 29 2008, Victor Lowther wrote:
> > > On Jan 29, 2008 12:22 PM, Richard Hughes <[EMAIL PROTECTED]> wrote:
> > > > On Mon, 2008-01-28 at 23:12 +0100, Till Maas wrote:
> > > > > Here is now a patch agains pm-utils git with /var/run/pm-utils/lock
> > > > > as
> > > > > lockfile. It also makes sure that /var/run/pm-utils, i.e. the
> > > > > directory for
> > > > > the lockfile is generated, and it uses variables for the directories
> > > > > to store
> > > > > state and service information and creates/removes them properly. They
> > > > > are now
> > > > > subdirectories of /var/run/pm-utils.
> > > >
> > > > Applied, thanks.
> > >
> > > You should probably reverse this patch and apply Till's updated patch
> > > -- this one breaks 90clock locking due to quoting errors.
> >
> > To make this easier, here is the updated patch again.
>
> Done, thanks.

Earlier Victor and I discussed moving the sleep after the check in
spin_lock(). That got lost in the shuffle, so here's a new patch.

http://lists.freedesktop.org/archives/pm-utils/2008-January/000755.html

--
Dan
From 85a4b9bb5ecc06d60af2d4c057ccb548dce12d57 Mon Sep 17 00:00:00 2001
From: Dan Nicholson <[EMAIL PROTECTED]>
Date: Tue, 29 Jan 2008 13:10:08 -0800
Subject: [PATCH] spin_lock: Sleep after checking that the timeout has elapsed

When the check for the lock file exists, we sleep and then check again
if a specified timeout hasn't elapsed. This patch moves the sleep after
the check so we are not penalized an extra `sleep 1'.
---
 pm/functions |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pm/functions b/pm/functions
index c456779..1e8b6ad 100755
--- a/pm/functions
+++ b/pm/functions
@@ -59,9 +59,9 @@ spin_lock()
 	# $2 = optional timeout
 	local elapsed=0
 	while ! try_lock $1; do
-		sleep 1;
 		[ "x$2" != "x" ] && [ $(( $elapsed == $2 )) -ne 0 ] && return 1
 		elapsed=$(($elapsed + 1))
+		sleep 1
 	done
 }
 
-- 
1.5.3.2

_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to