mirror of
https://github.com/apache/nuttx.git
synced 2026-08-10 06:55:13 +00:00
fs_epoll: [bug fix] EPOLL_CTL_ADD/MOD consider the teardown list too
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
This commit is contained in:
parent
4075509579
commit
2f2176151e
1 changed files with 34 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue