PERFORCE change 136771 for review
Roman Divacky
rdivacky at FreeBSD.org
Mon Mar 3 23:15:05 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=136771
Change 136771 by rdivacky at rdivacky_witten on 2008/03/03 23:14:36
The copyout callback can also be called when there's an error
during registration of a filter. Check this condition and store
the error in event->data and pick the error up if we trigger
such conditioin epoll_ctl().
Affected files ...
.. //depot/projects/soc2007/rdivacky/linux_epoll/sys/compat/linux/linux_epoll.c#9 edit
Differences ...
==== //depot/projects/soc2007/rdivacky/linux_epoll/sys/compat/linux/linux_epoll.c#9 (text+ko) ====
@@ -29,10 +29,12 @@
#include "opt_compat.h"
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/event.h>
+#include <sys/proc.h>
#include <sys/sysproto.h>
#include <sys/syscallsubr.h>
#include <sys/timespec.h>
@@ -81,12 +83,16 @@
EV_SET(kevent, fd, filter, flags, 0, 0, 0);
}
-/* Structure converting function from kevent to epoll. */
+/*
+ * Structure converting function from kevent to epoll. In a case
+ * this is called on error in registration we store the error in
+ * event->data and pick it up later in linux_epoll_ctl().
+ */
static void
linux_kevent_to_epoll(struct kevent *kevent, struct linux_epoll_event *event)
{
if (kevent->flags & EV_ERROR) {
- /* XXX: error handling */
+ event->data = kevent->data;
return;
}
switch (kevent->filter) {
@@ -106,7 +112,8 @@
/*
* Copyout callback used by kevent. This converts kevent
* events to epoll events and copies them back to the
- * userspace.
+ * userspace. This is also called on error on registering
+ * of the filter.
*/
static int
linux_kev_copyout(void *arg, struct kevent *kevp, int count)
@@ -194,7 +201,14 @@
}
linux_epoll_to_kevent(args->fd, &le, &kev);
- return (kern_kevent(td, args->epfd, 1, 0, &k_ops, NULL));
+ error = kern_kevent(td, args->epfd, 1, 0, &k_ops, NULL);
+ /* Check if there was an error during registration. */
+ if (error == 0 && td->td_retval[0] != 0) {
+ /* The copyout callback stored the error there. */
+ error = le.data;
+ }
+
+ return (error);
}
/*
More information about the p4-projects
mailing list