Private
Public Access
2
0

iio: guard pthread_setcancelstate with HAVE_PTHREAD_CANCEL

Signed-off-by: Constantin Musca <constantin.musca@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Constantin Musca
2016-01-15 18:13:41 +02:00
committed by Brendan Le Foll
parent ab14b9de43
commit caebb8b1fb

View File

@@ -318,15 +318,21 @@ mraa_iio_trigger_handler(void* arg)
for (;;) {
if (mraa_iio_wait_event(dev->fp, &data[0], &read_size) == MRAA_SUCCESS) {
#ifdef HAVE_PTHREAD_CANCEL
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
#endif
// only can process if readsize >= enabled channel's datasize
for (i = 0; i < (read_size / dev->datasize); i++) {
dev->isr((void*)&data);
}
#ifdef HAVE_PTHREAD_CANCEL
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
#endif
} else {
// we must have got an error code so die nicely
#ifdef HAVE_PTHREAD_CANCEL
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
#endif
return NULL;
}
}
@@ -467,12 +473,18 @@ mraa_iio_event_handler(void* arg)
for (;;) {
if (mraa_iio_event_poll_nonblock(dev->fp_event, &data) == MRAA_SUCCESS) {
#ifdef HAVE_PTHREAD_CANCEL
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
#endif
dev->isr_event(&data, dev->isr_args);
#ifdef HAVE_PTHREAD_CANCEL
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
#endif
} else {
// we must have got an error code so die nicely
#ifdef HAVE_PTHREAD_CANCEL
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
#endif
return NULL;
}
}