summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
diff options
context:
space:
mode:
authorprovos <provos@openbsd.org>2001-06-05 18:28:18 +0000
committerprovos <provos@openbsd.org>2001-06-05 18:28:18 +0000
commit6b5a078eafc8a2cd4955210b3437b3b0c8592ce0 (patch)
tree28d6d616c43515f0ca596dfdc2611632a56a7854 /sys/kern/sys_pipe.c
parentlet session_close() delete the pty. deny x11fwd if xauthfile is set. (diff)
downloadwireguard-openbsd-6b5a078eafc8a2cd4955210b3437b3b0c8592ce0.tar.xz
wireguard-openbsd-6b5a078eafc8a2cd4955210b3437b3b0c8592ce0.zip
fix kqueue EVFILT_WRITE; okay art@
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r--sys/kern/sys_pipe.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 64639a36b4f..f60b7ec9f69 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.31 2001/05/26 04:16:08 art Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.32 2001/06/05 18:28:18 provos Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -817,19 +817,23 @@ int
pipe_kqfilter(struct file *fp, struct knote *kn)
{
struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
+ struct pipe *wpipe = rpipe->pipe_peer;
switch (kn->kn_filter) {
case EVFILT_READ:
kn->kn_fop = &pipe_rfiltops;
+ SLIST_INSERT_HEAD(&rpipe->pipe_sel.si_note, kn, kn_selnext);
break;
case EVFILT_WRITE:
+ if (wpipe == NULL)
+ return (1);
kn->kn_fop = &pipe_wfiltops;
+ SLIST_INSERT_HEAD(&wpipe->pipe_sel.si_note, kn, kn_selnext);
break;
default:
return (1);
}
- SLIST_INSERT_HEAD(&rpipe->pipe_sel.si_note, kn, kn_selnext);
return (0);
}
@@ -837,8 +841,18 @@ void
filt_pipedetach(struct knote *kn)
{
struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
+ struct pipe *wpipe = rpipe->pipe_peer;
- SLIST_REMOVE(&rpipe->pipe_sel.si_note, kn, knote, kn_selnext);
+ switch (kn->kn_filter) {
+ case EVFILT_READ:
+ SLIST_REMOVE(&rpipe->pipe_sel.si_note, kn, knote, kn_selnext);
+ break;
+ case EVFILT_WRITE:
+ if (wpipe == NULL)
+ return;
+ SLIST_REMOVE(&wpipe->pipe_sel.si_note, kn, knote, kn_selnext);
+ break;
+ }
}
/*ARGSUSED*/