You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/11/25 13:34:15 UTC
[nuttx] branch master updated: fs_epoll: [bug fix] EPOLL_CTL_ADD/MOD consider the teardown list too
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/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 2f2176151e fs_epoll: [bug fix] EPOLL_CTL_ADD/MOD consider the teardown list too
2f2176151e is described below
commit 2f2176151e9a7b479dd6fa472ae6eaa045c28fb6
Author: wangbowen6 <wa...@xiaomi.com>
AuthorDate: Fri Nov 25 18:56:53 2022 +0800
fs_epoll: [bug fix] EPOLL_CTL_ADD/MOD consider the teardown list too
Signed-off-by: wangbowen6 <wa...@xiaomi.com>
---
fs/vfs/fs_epoll.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c
index 1e31b7160f..0886c7c5a2 100644
--- a/fs/vfs/fs_epoll.c
+++ b/fs/vfs/fs_epoll.c
@@ -418,6 +418,15 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
}
}
+ list_for_every_entry(&eph->teardown, epn, epoll_node_t, node)
+ {
+ if (epn->pfd.fd == fd)
+ {
+ ret = -EEXIST;
+ goto err;
+ }
+ }
+
if (list_is_empty(&eph->free))
{
/* Malloc new epoll node, insert the first list_node to the
@@ -508,6 +517,31 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
}
}
+ goto out;
+ }
+ }
+
+ list_for_every_entry(&eph->teardown, epn, epoll_node_t, node)
+ {
+ if (epn->pfd.fd == fd)
+ {
+ if (epn->pfd.events != ev->events)
+ {
+ epn->data = ev->data;
+ epn->pfd.events = ev->events;
+ epn->pfd.fd = fd;
+ epn->pfd.revents = 0;
+
+ ret = poll_fdsetup(fd, &epn->pfd, true);
+ if (ret < 0)
+ {
+ goto err;
+ }
+
+ list_delete(&epn->node);
+ list_add_tail(&eph->setup, &epn->node);
+ }
+
break;
}
}