A new thread is created when setting interrupted callback on gpio pin,
which is polling and reading in loop. Reading at the same time from main
thread makes race condition as it is doing lseek() and read() on static
variable gpio->fd_value. This is fixed by adding mutex to
peripheral_gpio_read().
Change-Id: I55508fc36b91993226b373d460407c40d551276f
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
int ret;
int length = 1;
char gpio_buf[GPIO_BUFFER_MAX] = {0, };
+ static GMutex mutex;
+ g_mutex_lock(&mutex);
lseek(gpio->fd_value, 0, SEEK_SET);
ret = read(gpio->fd_value, &gpio_buf, length);
+ g_mutex_unlock(&mutex);
+
CHECK_ERROR(ret != length);
if (gpio_buf[0] == '0') {