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
The following commit(s) were added to refs/heads/master by this push:
new f33ab4cbbf8 fs/epoll: keep failed MOD nodes out of the setup list
f33ab4cbbf8 is described below
commit f33ab4cbbf82e46d645027a4772c2a04043be8eb
Author: Bowen Wang <[email protected]>
AuthorDate: Thu Nov 12 14:46:19 2026 +0800
fs/epoll: keep failed MOD nodes out of the setup list
EPOLL_CTL_MOD of a node in the setup list tears the old registration
down and registers the new events. If that registration fails, the
node stays in the setup list unregistered. Every node in the setup
list is assumed registered: epoll_do_close() and epoll_teardown() tear
it down again, so the driver sees one teardown more than setups.
Move the node to the teardown list instead, which epoll_setup()
retries on the next epoll_wait().
Also destroy eph->sem in epoll_do_close() and on the epoll_do_create()
failure path; it was initialized but never destroyed.
Signed-off-by: Bowen Wang <[email protected]>
Signed-off-by: jingfei <[email protected]>
---
fs/vfs/fs_epoll.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c
index ac913c676b4..b152c930494 100644
--- a/fs/vfs/fs_epoll.c
+++ b/fs/vfs/fs_epoll.c
@@ -220,6 +220,7 @@ static int epoll_do_close(FAR struct file *filep)
nxmutex_unlock(&eph->lock);
nxmutex_destroy(&eph->lock);
+ nxsem_destroy(&eph->sem);
fs_heap_free(eph);
}
else
@@ -286,6 +287,7 @@ static int epoll_do_create(int size, int flags)
if (fd < 0)
{
nxmutex_destroy(&eph->lock);
+ nxsem_destroy(&eph->sem);
fs_heap_free(eph);
set_errno(-fd);
return ERROR;
@@ -704,6 +706,12 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct
epoll_event *ev)
ret = file_poll(epn->filep, &epn->pfd, true);
if (ret < 0)
{
+ /* Only registered nodes may stay in the setup list:
+ * close and teardown tear down whatever is there.
+ */
+
+ list_delete(&epn->node);
+ list_add_tail(&eph->teardown, &epn->node);
goto err;
}
}