uloop: fix deleting pending fd events on uloop_fd_del
When a fd gets deleted internally due to errors, fd->registered gets set to false before events are moved to the staging array. This leads to pending events not getting cleared properly when the fd user finally calls uloop_fd_del. Fix this by moving the check down and always checking for pending events. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
parent
ef9b6b92df
commit
04f194aa8a
1 changed files with 4 additions and 3 deletions
7
uloop.c
7
uloop.c
|
@ -392,15 +392,16 @@ int uloop_fd_delete(struct uloop_fd *fd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!fd->registered)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < cur_nfds; i++) {
|
for (i = 0; i < cur_nfds; i++) {
|
||||||
if (cur_fds[cur_fd + i].fd != fd)
|
if (cur_fds[cur_fd + i].fd != fd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
cur_fds[cur_fd + i].fd = NULL;
|
cur_fds[cur_fd + i].fd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fd->registered)
|
||||||
|
return 0;
|
||||||
|
|
||||||
fd->registered = false;
|
fd->registered = false;
|
||||||
uloop_fd_stack_event(fd, -1);
|
uloop_fd_stack_event(fd, -1);
|
||||||
return __uloop_fd_delete(fd);
|
return __uloop_fd_delete(fd);
|
||||||
|
|
Loading…
Reference in a new issue