summaryrefslogtreecommitdiff
path: root/files/common
diff options
context:
space:
mode:
authorKatze Miau <miaukatzemiau@priveasy.de>2011-12-18 22:36:44 (GMT)
committerKatze Miau <miaukatzemiau@priveasy.de>2011-12-18 22:36:44 (GMT)
commitb5d264dc02e318d56038ad785b9f5dc0b301926b (patch)
tree94e5ed3479d4c6cd542fa02abee1ff587dcff2e8 /files/common
parentaab95b2e80c19e0c296c46cedabfbad4f27af047 (diff)
fsm: do not lock state file when reading state
Locking the state file during `fsm get` operations is annoying. And the returned state may be changed anytime after termination, so the caller can not rely on it being up to date anyway.
Diffstat (limited to 'files/common')
-rwxr-xr-xfiles/common/sbin/fsm15
1 files changed, 10 insertions, 5 deletions
diff --git a/files/common/sbin/fsm b/files/common/sbin/fsm
index 0bfe4ba..e6b62fa 100755
--- a/files/common/sbin/fsm
+++ b/files/common/sbin/fsm
@@ -53,6 +53,14 @@ callOne () { # args: cwd arg1 arg2 cmdlist
done )
}
+lockState () {
+ # lock state file (neccessary also for watch, as it calls scripts
+ # that assume a certain state as active during their whole
+ # execution time)
+ exec 666<$1
+ flock -x 666
+}
+
fail() {
echo "$1" 1>&2
exit 1
@@ -81,20 +89,17 @@ else
fail "FSM $2 does not exist"
fi
-# lock state file (neccessary also for watch, as it calls scripts that
-# assume a certain state as active during their whole execution time)
-exec 666<$PState
-flock -x 666
-
case "$1" in
get)
cat $PState
;;
watch)
+ lock $PState
watch
;;
change)
[ -n "$3" ] || printArgs
+ lock $PState
change $3
;;
*)
contact: Jan Huwald // Impressum