zephyr/lib/posix
Marcin Niestroj 063dd51dc7 lib: posix: eventfd: fix read/poll after multiple writes
So far semaphore was used with possible values in range 0 to
UINT32_MAX. Each write resulted in semaphore increment. As an example
after two writes and single read eventfd counter was correctly zeroed,
but semaphore counter was not. This means that poll() signalled at this
stage POLLIN (semaphore counter was > 0), but it clearly should
not (eventfd counter == 0). Blocking version of read() was also
returning immediately, returning 0 as previous eventfd counter.

Change read_sem to be a binary semaphore, which counter represents
eventfd counter being zero (when semaphore counter == 0) or
non-zero (when semaphore counter == 1). Try to take the semaphore in
eventfd read() and decrement eventfd counter when semaphore was ready.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-20 16:21:37 +02:00
..
clock.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
CMakeLists.txt lib: posix: nanosleep 2020-06-12 17:02:03 +02:00
eventfd.c lib: posix: eventfd: fix read/poll after multiple writes 2020-07-20 16:21:37 +02:00
fs.c posix/fs: Fix POSIX lseek to return position upon completion 2020-07-04 07:46:51 -04:00
Kconfig lib: posix: Update to new timeout API 2020-05-08 17:31:45 +02:00
mqueue.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
nanosleep.c lib: posix: nanosleep 2020-06-12 17:02:03 +02:00
pthread.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
pthread_barrier.c all: Update reserved function names 2019-03-11 13:48:42 -04:00
pthread_common.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
pthread_cond.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
pthread_key.c posix: add pthread_key and pthread_once APIs 2018-07-19 08:46:33 -04:00
pthread_mutex.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
pthread_rwlock.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
pthread_sched.c lib: posix: Move posix layer from 'kernel' to 'lib' 2018-04-05 16:43:05 -04:00
semaphore.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
sleep.c timeout: Fix up API usage 2020-03-31 19:40:47 -04:00
timer.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00