From 0ddefd7c699292ec5a2364c59809a181f90a7a4d Mon Sep 17 00:00:00 2001 From: spiriou Date: Sat, 15 Aug 2020 22:05:24 +0200 Subject: [PATCH] fs/vfs/fs_epoll: fix epoll_wait function --- fs/vfs/fs_epoll.c | 7 ++++++- include/sys/epoll.h | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c index f6f9bdf01a..8aebbdca9c 100644 --- a/fs/vfs/fs_epoll.c +++ b/fs/vfs/fs_epoll.c @@ -245,7 +245,12 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, /* Iterate over non NULL event fds */ - for (i = 0, counter = 0; i < rc && counter < eph->size; counter++) + if (rc > maxevents) + { + rc = maxevents; + } + + for (i = 0, counter = 0; i < rc && counter < eph->occupied; counter++) { if (eph->evs[counter].revents != 0) { diff --git a/include/sys/epoll.h b/include/sys/epoll.h index d8f221972b..bf0200f2a4 100644 --- a/include/sys/epoll.h +++ b/include/sys/epoll.h @@ -95,11 +95,11 @@ struct epoll_event { epoll_data_t data; pollevent_t events; /* The input event flags */ - pollevent_t revents; /* The output event flags */ /* Non-standard fields used internally by NuttX. */ - void *reserved; /* reserved feild sync with struct pollfd */ + pollevent_t revents; /* The output event flags */ + void *reserved; /* reserved field sync with struct pollfd */ FAR sem_t *sem; /* Pointer to semaphore used to post output event */ FAR void *priv; /* For use by drivers */ };