From: Michael Tremer Date: Sun, 17 Jan 2016 18:37:10 +0000 (+0100) Subject: lock: Decrease the number of iterations per second X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9e3f4a245e32e58f8ca674f4145cad1ef7ef198;p=people%2Fjschlag%2Fnetwork.git lock: Decrease the number of iterations per second There have been reports about that this locking mechanism wasn't too stable on their machines which can totally be the case judging by the design of it. However there is no other easy way to implement this any better without any native C helper which I would like to avoid at this moment. So I decreased the amount of ticks which should make any processes running at the same time less likely to collide. Fixes #10979 Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.lock b/src/functions/functions.lock index 136a223..b09b0b3 100644 --- a/src/functions/functions.lock +++ b/src/functions/functions.lock @@ -24,10 +24,10 @@ lock_acquire() { assert isset lockfile # timeout value in seconds - local timeout=60 - timeout=$(( ${timeout} * 10 )) + local timeout=120 + timeout=$(( ${timeout} * 4 )) - log DEBUG "Acquiring lock '${lockfile}'." + log DEBUG "Acquiring lock '${lockfile}'" local free="false" while [ ${timeout} -gt 0 ]; do @@ -37,10 +37,10 @@ lock_acquire() { fi timeout=$(( ${timeout} - 1 )) - sleep 0.1 + sleep 0.25 done - assert ${free} "Could not acquire lock '${lockfile}'." + assert ${free} "Could not acquire lock '${lockfile}'" # Write out pid to the lockfile and make sure that # nobody else can access it. @@ -51,7 +51,7 @@ lock_acquire() { lock_release() { local lockfile="${1}" - log DEBUG "Releasing lock '${lockfile}'." + log DEBUG "Releasing lock '${lockfile}'" # Remove the lockfile (okay if it does not exist). rm -f ${lockfile}