hbbs

bbs.hlirc.net
Log | Files | Refs | README | LICENSE

commit 13da50619b140208ff47d2a3007d2ee743324437
parent d2aed92b34ff521498b2047d489ced78d1dd86cb
Author: hhvn <hayden@haydenvh.com>
Date:   Wed,  3 Feb 2021 14:24:35 +0000

bin/wrapper.sh hbbs.sh include/common.sh include/lock.sh: unlock all databases upon losing connexion

Diffstat:
Mbin/wrapper.sh | 2+-
Mhbbs.sh | 4++++
Minclude/common.sh | 1+
Minclude/lock.sh | 10++++++++++
4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/bin/wrapper.sh b/bin/wrapper.sh @@ -1,4 +1,4 @@ #!/bin/sh cwd=$(dirname $0) -$cwd/../hbbs.sh $@ 2>/dev/null +exec $cwd/../hbbs.sh $@ 2>/dev/null diff --git a/hbbs.sh b/hbbs.sh @@ -2,6 +2,10 @@ trap 'die "SIGINT received"' 2 +# xinetd +trap 'die "connection lost"' 1 #SIGHUP +trap 'die "connection lost"' 13 #SIGPIPE + export cwd=$(dirname $0) . $cwd/include/common.sh . $cwd/include/log.sh diff --git a/include/common.sh b/include/common.sh @@ -8,6 +8,7 @@ bin(){ } die(){ + unlock_all error "$@" exit 1 } diff --git a/include/lock.sh b/include/lock.sh @@ -1,6 +1,7 @@ #!/bin/sh lock(){ + locklist=$(echo "$locklist"; echo "$1") while [ -f $1.lock ] do sleep 0.5 @@ -9,5 +10,14 @@ lock(){ } unlock(){ + locklist=$(echo "$locklist" | grep -v "^$1$") rm $1.lock } + +unlock_all(){ + for f in $locklist + do + rm $f.lock + done + locklist="" +}