| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_event.c,v 1.99 2017/11/30 05:52:40 riastradh Exp $ */ | | 1 | /* $NetBSD: kern_event.c,v 1.100 2017/11/30 14:19:27 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -48,27 +48,27 @@ | | | @@ -48,27 +48,27 @@ |
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
55 | * SUCH DAMAGE. | | 55 | * SUCH DAMAGE. |
56 | * | | 56 | * |
57 | * FreeBSD: src/sys/kern/kern_event.c,v 1.27 2001/07/05 17:10:44 rwatson Exp | | 57 | * FreeBSD: src/sys/kern/kern_event.c,v 1.27 2001/07/05 17:10:44 rwatson Exp |
58 | */ | | 58 | */ |
59 | | | 59 | |
60 | #include <sys/cdefs.h> | | 60 | #include <sys/cdefs.h> |
61 | __KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.99 2017/11/30 05:52:40 riastradh Exp $"); | | 61 | __KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.100 2017/11/30 14:19:27 christos Exp $"); |
62 | | | 62 | |
63 | #include <sys/param.h> | | 63 | #include <sys/param.h> |
64 | #include <sys/systm.h> | | 64 | #include <sys/systm.h> |
65 | #include <sys/kernel.h> | | 65 | #include <sys/kernel.h> |
66 | #include <sys/wait.h> | | 66 | #include <sys/wait.h> |
67 | #include <sys/proc.h> | | 67 | #include <sys/proc.h> |
68 | #include <sys/file.h> | | 68 | #include <sys/file.h> |
69 | #include <sys/select.h> | | 69 | #include <sys/select.h> |
70 | #include <sys/queue.h> | | 70 | #include <sys/queue.h> |
71 | #include <sys/event.h> | | 71 | #include <sys/event.h> |
72 | #include <sys/eventvar.h> | | 72 | #include <sys/eventvar.h> |
73 | #include <sys/poll.h> | | 73 | #include <sys/poll.h> |
74 | #include <sys/kmem.h> | | 74 | #include <sys/kmem.h> |
| @@ -1053,26 +1053,33 @@ kqueue_register(struct kqueue *kq, struc | | | @@ -1053,26 +1053,33 @@ kqueue_register(struct kqueue *kq, struc |
1053 | } else { | | 1053 | } else { |
1054 | /* Otherwise, knote is on an fd. */ | | 1054 | /* Otherwise, knote is on an fd. */ |
1055 | list = (struct klist *) | | 1055 | list = (struct klist *) |
1056 | &fdp->fd_dt->dt_ff[kn->kn_id]->ff_knlist; | | 1056 | &fdp->fd_dt->dt_ff[kn->kn_id]->ff_knlist; |
1057 | if ((int)kn->kn_id > fdp->fd_lastkqfile) | | 1057 | if ((int)kn->kn_id > fdp->fd_lastkqfile) |
1058 | fdp->fd_lastkqfile = kn->kn_id; | | 1058 | fdp->fd_lastkqfile = kn->kn_id; |
1059 | } | | 1059 | } |
1060 | SLIST_INSERT_HEAD(list, kn, kn_link); | | 1060 | SLIST_INSERT_HEAD(list, kn, kn_link); |
1061 | | | 1061 | |
1062 | KERNEL_LOCK(1, NULL); /* XXXSMP */ | | 1062 | KERNEL_LOCK(1, NULL); /* XXXSMP */ |
1063 | error = (*kfilter->filtops->f_attach)(kn); | | 1063 | error = (*kfilter->filtops->f_attach)(kn); |
1064 | KERNEL_UNLOCK_ONE(NULL); /* XXXSMP */ | | 1064 | KERNEL_UNLOCK_ONE(NULL); /* XXXSMP */ |
1065 | if (error != 0) { | | 1065 | if (error != 0) { |
| | | 1066 | #ifdef DEBUG |
| | | 1067 | printf("%s: event type %d not supported for " |
| | | 1068 | "file type %d (error %d)\n", __func__, |
| | | 1069 | kn->kn_filter, kn->kn_obj ? |
| | | 1070 | ((file_t *)kn->kn_obj)->f_type : -1, error); |
| | | 1071 | #endif |
| | | 1072 | |
1066 | /* knote_detach() drops fdp->fd_lock */ | | 1073 | /* knote_detach() drops fdp->fd_lock */ |
1067 | knote_detach(kn, fdp, false); | | 1074 | knote_detach(kn, fdp, false); |
1068 | goto done; | | 1075 | goto done; |
1069 | } | | 1076 | } |
1070 | atomic_inc_uint(&kfilter->refcnt); | | 1077 | atomic_inc_uint(&kfilter->refcnt); |
1071 | } else { | | 1078 | } else { |
1072 | /* | | 1079 | /* |
1073 | * The user may change some filter values after the | | 1080 | * The user may change some filter values after the |
1074 | * initial EV_ADD, but doing so will not reset any | | 1081 | * initial EV_ADD, but doing so will not reset any |
1075 | * filter which have already been triggered. | | 1082 | * filter which have already been triggered. |
1076 | */ | | 1083 | */ |
1077 | kn->kn_sfflags = kev->fflags; | | 1084 | kn->kn_sfflags = kev->fflags; |
1078 | kn->kn_sdata = kev->data; | | 1085 | kn->kn_sdata = kev->data; |