# HG changeset patch # User Michiel Broek # Date 1425724390 -3600 # Node ID 608592f74b10bd827f42c485266138c55cebe1e2 # Parent 1dc57faf5ab599215ae5eace09b8fb11c1d7d5bd Added extra lock diff -r 1dc57faf5ab5 -r 608592f74b10 thermferm/devices.c --- a/thermferm/devices.c Fri Feb 20 16:07:39 2015 +0100 +++ b/thermferm/devices.c Sat Mar 07 11:33:10 2015 +0100 @@ -166,7 +166,8 @@ int device_out(char *uuid, int value) { devices_list *device; - time_t now; + time_t now, my_timestamp; + int my_value; #ifdef HAVE_WIRINGPI_H int i, rc; char buf[40]; @@ -184,7 +185,15 @@ * every 2 minutes because commands can have temporary * disconnects, or have radio problems. */ - if ((value != device->value) || (((int)now - (int)device->timestamp) > 120)) { +#ifdef HAVE_WIRINGPI_H + piLock(LOCK_DEVICES); +#endif + my_timestamp = device->timestamp; + my_value = device->value; +#ifdef HAVE_WIRINGPI_H + piUnlock(LOCK_DEVICES); +#endif + if ((value != my_value) || (((int)now - (int)my_timestamp) > 120)) { #ifdef HAVE_WIRINGPI_H rc = 0;