Linux epoll: Register events with zero event mask

Such an events are legal and should be interpreted as EPOLLERR | EPOLLHUP.
Register a disabled kqueue event in that case as we do not support EPOLLHUP yet.

Required by Linux Steam client.

PR:		240590
Reported by:	Alex S <iwtcex@gmail.com>
Reviewed by:	emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D22516
This commit is contained in:
wulf 2019-11-24 20:47:40 +00:00
parent 73dfdf541d
commit b52750f436
2 changed files with 7 additions and 2 deletions

View File

@ -325,6 +325,11 @@ epoll_to_kevent(struct thread *td, int fd, struct epoll_event *l_event,
EV_SET(kevent++, fd, EVFILT_WRITE, kev_flags, 0, 0, 0);
++(*nkevents);
}
/* zero event mask is legal */
if ((levents & (LINUX_EPOLL_EVRD | LINUX_EPOLL_EVWR)) == 0) {
EV_SET(kevent++, fd, EVFILT_READ, EV_ADD|EV_DISABLE, 0, 0, 0);
++(*nkevents);
}
if ((levents & ~(LINUX_EPOLL_EVSUP)) != 0) {
p = td->td_proc;

View File

@ -45,10 +45,10 @@
#define LINUX_EPOLLONESHOT 1u<<30
#define LINUX_EPOLLET 1u<<31
#define LINUX_EPOLL_EVRD (LINUX_EPOLLIN|LINUX_EPOLLRDNORM \
|LINUX_EPOLLHUP|LINUX_EPOLLERR|LINUX_EPOLLPRI)
#define LINUX_EPOLL_EVRD (LINUX_EPOLLIN|LINUX_EPOLLRDNORM)
#define LINUX_EPOLL_EVWR (LINUX_EPOLLOUT|LINUX_EPOLLWRNORM)
#define LINUX_EPOLL_EVSUP (LINUX_EPOLLET|LINUX_EPOLLONESHOT \
|LINUX_EPOLLHUP|LINUX_EPOLLERR|LINUX_EPOLLPRI \
|LINUX_EPOLL_EVRD|LINUX_EPOLL_EVWR|LINUX_EPOLLRDHUP)
#define LINUX_EPOLL_CTL_ADD 1