diff options
author | Niels Provos <provos@cvs.openbsd.org> | 2001-06-05 18:28:19 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 2001-06-05 18:28:19 +0000 |
commit | bf8bf72f7623f932ade9850057869346112a3fea (patch) | |
tree | b957233d6579836babdca9402058de8b3ed45dc6 /sys/kern/sys_pipe.c | |
parent | dcae085862534572c4126f94bfb56f46970f7455 (diff) |
fix kqueue EVFILT_WRITE; okay art@
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r-- | sys/kern/sys_pipe.c | 20 |
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*/ |