Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Feb 2017 19:54:22 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r314403 - head/sys/compat/linux
Message-ID:  <201702281954.v1SJsMSV011750@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Tue Feb 28 19:54:22 2017
New Revision: 314403
URL: https://svnweb.freebsd.org/changeset/base/314403

Log:
  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

Modified:
  head/sys/compat/linux/linux_event.c

Modified: head/sys/compat/linux/linux_event.c
==============================================================================
--- head/sys/compat/linux/linux_event.c	Tue Feb 28 19:49:21 2017	(r314402)
+++ head/sys/compat/linux/linux_event.c	Tue Feb 28 19:54:22 2017	(r314403)
@@ -483,11 +483,6 @@ linux_epoll_ctl(struct thread *td, struc
 
 	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, st
 	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 *t
 	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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201702281954.v1SJsMSV011750>