This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 46c19f92c49eeec429373c0a90e1a8fe8d11f85b Author: Bowen Wang <[email protected]> AuthorDate: Fri Sep 4 15:22:45 2026 +0800 fs/eventfd: skip poll setup notification when no event is requested eventfd_do_poll() builds an eventset that is never empty: counter == 0 yields POLLOUT, counter > 0 yields POLLIN. It then notifies unconditionally. An epoll node carries POLLALWAYS, so poll_notify() runs the callback even when the eventset is masked away to nothing, and epoll_default_cb() marks that node notified. Nothing is ever reported, yet epoll_wait() tears the fd down and sets it up again on every call: epoll_wait -> epoll_setup -> file_poll(true) -> notified = true -> epoll_teardown -> file_poll(false), revents == 0 (repeat forever) Notify only when the eventset intersects what this fd asked for. The mask is the one poll_notify() applies, and revents is 0 on every setup path, so skipping the call is equivalent to making it. Signed-off-by: Bowen Wang <[email protected]> --- fs/vfs/fs_eventfd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/vfs/fs_eventfd.c b/fs/vfs/fs_eventfd.c index ece6f6af024..f38f8e8fcbe 100644 --- a/fs/vfs/fs_eventfd.c +++ b/fs/vfs/fs_eventfd.c @@ -516,7 +516,15 @@ static int eventfd_do_poll(FAR struct file *filep, FAR struct pollfd_s *fds, eventset |= POLLIN; } - poll_notify(&fds, 1, eventset); + /* The eventset is never empty and an epoll node sets POLLALWAYS, so + * notifying unconditionally would make epoll_wait() tear down and set + * up this fd on every call while reporting nothing. + */ + + if ((eventset & (fds->events | POLLERR | POLLHUP)) != 0) + { + poll_notify(&fds, 1, eventset); + } out: nxmutex_unlock(&dev->lock);
