From 4b690b4b7f132840aaf6558b7c53b570f0232b92 Mon Sep 17 00:00:00 2001 From: lejubila Date: Mon, 18 Sep 2017 18:55:52 +0200 Subject: [PATCH] variato gestione funzioni di lock/unlock per incrementare le prestazioni --- CHANGELOG.md | 1 + piGarden.sh | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 292fdd7..ccb643c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Fix problem with cron management on similar type cron - Fix bug: in case of rain the weather data were not updated - Fix bug: delete the temporary files for managing the socket server messages that were kept on the system +- Change manage of the lock/unlock function for encrase performance (do you need manualy remove the file /var/shm/piGarden.lock or /tmp/piGarden.lock) ## 0.4.4 - 17/06/2017 - Remove lock/unlock from init function for resove bug diff --git a/piGarden.sh b/piGarden.sh index f968bd7..150a749 100755 --- a/piGarden.sh +++ b/piGarden.sh @@ -658,16 +658,12 @@ list_descendants () # function lock { - sleep 0.$((100 * $RANDOM / 32767)) | $SED 's/..$/.&/' - local max_time=10 local current_time=$(($1 + 1)) - local lock_content=`cat "$LOCK_FILE" 2> /dev/null` - if [ -z $lock_content ]; then - lock_content="0" - fi - if [ "$lock_content" -eq "1" ]; then + if mkdir "${LOCK_FILE}" &>/dev/null; then + local foo=bar + else if [ "$current_time" -gt "$max_time" ]; then log_write "Maximum locked time reached" sleep $max_time @@ -679,19 +675,22 @@ function lock { lock $current_time return fi - echo "1" > "$LOCK_FILE" } + + # # Chidue un lock # function unlock { - echo "0" > "$LOCK_FILE" + rmdir "${LOCK_FILE}" &>/dev/null } + + # # Invia l'identificativo univoco ad uso statistico di utilizzo #