]> git.ipfire.org Git - network.git/commitdiff
lock: Decrease the number of iterations per second
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jan 2016 18:37:10 +0000 (19:37 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jan 2016 18:37:10 +0000 (19:37 +0100)
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 <michael.tremer@ipfire.org>
src/functions/functions.lock

index 136a223c443c883535a24f2d327f91ed40a7607b..b09b0b3623ecb7f4569605675fff1eb6fc04a974 100644 (file)
@@ -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}