variato gestione funzioni di lock/unlock per incrementare le prestazioni
This commit is contained in:
@@ -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
|
||||
|
||||
17
piGarden.sh
17
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
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user