This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 0ddefd7 fs/vfs/fs_epoll: fix epoll_wait function
0ddefd7 is described below
commit 0ddefd7c699292ec5a2364c59809a181f90a7a4d
Author: spiriou <[email protected]>
AuthorDate: Sat Aug 15 22:05:24 2020 +0200
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 f6f9bdf..8aebbdc 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 d8f2219..bf0200f 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 */
};