fs/vfs: Implement EPOLLONESHOT flag

https://linux.die.net/man/2/epoll_ctl:
EPOLLONESHOT (since Linux 2.6.2)
Sets the one-shot behavior for the associated file descriptor.
This means that after an event is pulled out with epoll_wait(2)
the associated file descriptor is internally disabled and
no other events will be reported by the epoll interface.
The user must call epoll_ctl() with EPOLL_CTL_MOD to
rearm the file descriptor with a new event mask.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I6c0dc93e1cdae0e8cea5b487c7005de2da2c2ec3
This commit is contained in:
Xiang Xiao 2020-08-17 01:32:21 +08:00 committed by Abdelatif Guettouche
parent 6c9ff72b9a
commit a354b9a9d1
2 changed files with 7 additions and 0 deletions

View File

@ -263,6 +263,11 @@ int epoll_pwait(int epfd, FAR struct epoll_event *evs,
{
evs[i].data.fd = eph->evs[counter].data.fd;
evs[i].events = eph->evs[counter].revents;
if (eph->evs[counter].events & EPOLLONESHOT)
{
eph->evs[counter].events = 0; /* Disable oneshot internally */
}
i += 1;
}
}

View File

@ -74,6 +74,8 @@ enum EPOLL_EVENTS
#define EPOLLERR EPOLLERR
EPOLLHUP = POLLHUP,
#define EPOLLHUP EPOLLHUP
EPOLLONESHOT = 1u << 30,
#define EPOLLONESHOT EPOLLONESHOT
};
/* Flags to be passed to epoll_create1. */