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 5558477c90234b7c82d233c32096d47d5f069858 Author: Bowen Wang <[email protected]> AuthorDate: Fri Sep 4 15:22:45 2026 +0800 fs/mqueue: skip poll setup notification when no event is requested Same defect as eventfd. nxmq_file_poll() builds an eventset that is never empty: nmsgs == 0 yields POLLOUT, nmsgs > 0 yields POLLIN, and mq_open() rejects mq_maxmsg <= 0. 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 the node is marked notified. Watching an empty queue for EPOLLIN therefore makes epoll_wait() tear the fd down and set it up again on every call while reporting nothing. 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/mqueue/mq_open.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/mqueue/mq_open.c b/fs/mqueue/mq_open.c index a20acfd0cac..203522062f6 100644 --- a/fs/mqueue/mq_open.c +++ b/fs/mqueue/mq_open.c @@ -137,7 +137,15 @@ static int nxmq_file_poll(FAR struct file *filep, 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); + } } else if (fds->priv != NULL) {
