jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

commit 34eca4c60d2b0ecb596c1a3102daa0aa05b615cb
parent f7bb8d3db2b1d520d95b10c6920c7c6fbcecd941
Author: Jaromil <jaromil@dyne.org>
Date:   Sun,  4 May 2014 20:40:29 +0200

fix to locking (unlink is simplified)

Diffstat:
Msrc/zlibs/locking | 27+++++----------------------
1 file changed, 5 insertions(+), 22 deletions(-)

diff --git a/src/zlibs/locking b/src/zlibs/locking @@ -86,7 +86,7 @@ pidcheck() { # check if lock belongs to us unlock() { func "unlock: $1" - pidcheck $1 + pidcheck "$1" { test $? = 0 } || { return 1 } ${=dotlock} -u "$1" @@ -94,28 +94,11 @@ unlock() { rm -f "$1.lock" { test $? = 0 } || { error "Unable to unlock: $1"; return 1 } } - { test -r "${1}.pid" } && { rm -f ${1}.pid } + { test -r "${1}.pid" } && { rm -f "${1}.pid" } return 0 } unlink() { # delete a file that we are locking - func "unlink: $1" - # use with care! this can permanently erase currently locked files - - pidcheck $1 - { test $? = 0 } || { return 1 } - - { test -r ${1}.unlink } && { - error "Ongoing unlink detected on $1"; return 0 } - - # signal that is unlinking (for parallel operation) - touch ${1}.unlink - ( - ${=rm} ${1} - touch ${1} - ${=dotlock} -d -f ${1} - { test $? != 0 } && { error "Unable to unlink: $1"; return 1 } - { test -r "${1}.pid" } && { rm -f ${1}.pid } - rm -f ${1}.unlink - ) &! - return 0 + unlock "$1" + ${=rm} "$1" + func "$1 removed" }