From 8bc4edfd754e5c1284af576bc54606d9b49ddb2f Mon Sep 17 00:00:00 2001 From: Dmitry Chagin Date: Tue, 28 Feb 2017 19:54:22 +0000 Subject: [PATCH] Linux epoll return ENOENT error in case when op is EPOLL_CTL_MOD or EPOLL_CTL_DEL, and fd is not registered with this epoll instance. MFC after: 1 month --- sys/compat/linux/linux_event.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index e0c129329e46..4c29186380cf 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -483,11 +483,6 @@ linux_epoll_ctl(struct thread *td, struct linux_epoll_ctl_args *args) switch (args->op) { case LINUX_EPOLL_CTL_MOD: - /* - * We don't memorize which events were set for this FD - * on this level, so just delete all we could have set: - * EVFILT_READ and EVFILT_WRITE, ignoring any errors - */ error = epoll_delete_all_events(td, epfp, args->fd); if (error != 0) goto leave0; @@ -644,19 +639,11 @@ epoll_delete_event(struct thread *td, struct file *epfp, int fd, int filter) struct kevent_copyops k_ops = { &ciargs, NULL, epoll_kev_copyin}; - int error; ciargs.changelist = &kev; EV_SET(&kev, fd, filter, EV_DELETE | EV_DISABLE, 0, 0, 0); - error = kern_kevent_fp(td, epfp, 1, 0, &k_ops, NULL); - - /* - * here we ignore ENONT, because we don't keep track of events here - */ - if (error == ENOENT) - error = 0; - return (error); + return (kern_kevent_fp(td, epfp, 1, 0, &k_ops, NULL)); } static int @@ -667,8 +654,8 @@ epoll_delete_all_events(struct thread *td, struct file *epfp, int fd) error1 = epoll_delete_event(td, epfp, fd, EVFILT_READ); error2 = epoll_delete_event(td, epfp, fd, EVFILT_WRITE); - /* report any errors we got */ - return (error1 == 0 ? error2 : error1); + /* return 0 if at least one result positive */ + return (error1 == 0 ? 0 : error2); } static int