CDev::poll_notify_one: remove checking the semaphore counter

The check is unnecessary. In the worst case the semaphore gets unlocked
twice, but it's not an issue because the waiter is only interested in the
first sem_post(), and the semaphore is then not used anymore.
This commit is contained in:
Beat Küng
2018-07-30 23:06:32 +02:00
committed by Lorenz Meier
parent 72773b75c3
commit 99fd1f7213
+2 -11
View File
@@ -394,21 +394,12 @@ CDev::poll_notify_one(px4_pollfd_struct_t *fds, pollevent_t events)
{
DEVICE_DEBUG("CDev::poll_notify_one");
#ifdef __PX4_NUTTX
int value = fds->sem->semcount;
#else
int value = -1;
px4_sem_getvalue(fds->sem, &value);
#endif
/* update the reported event set */
fds->revents |= fds->events & events;
DEVICE_DEBUG(" Events fds=%p %0x %0x %0x %d", fds, fds->revents, fds->events, events, value);
DEVICE_DEBUG(" Events fds=%p %0x %0x %0x", fds, fds->revents, fds->events, events);
/* if the state is now interesting, wake the waiter if it's still asleep */
/* XXX semcount check here is a vile hack; counting semphores should not be abused as cvars */
if ((fds->revents != 0) && (value <= 0)) {
if (fds->revents != 0) {
px4_sem_post(fds->sem);
}
}