Correctly hook up the write kqfilter to pipes.

Submitted by:  Niels Provos <provos@citi.umich.edu>
This commit is contained in:
Jonathan Lemon 2001-06-15 20:45:01 +00:00
parent 931c1e20e4
commit 7b748f0a21
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=78292

View File

@ -1242,7 +1242,7 @@ pipeclose(cpipe)
static int
pipe_kqfilter(struct file *fp, struct knote *kn)
{
struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
struct pipe *cpipe = (struct pipe *)kn->kn_fp->f_data;
switch (kn->kn_filter) {
case EVFILT_READ:
@ -1250,21 +1250,23 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
break;
case EVFILT_WRITE:
kn->kn_fop = &pipe_wfiltops;
cpipe = cpipe->pipe_peer;
break;
default:
return (1);
}
SLIST_INSERT_HEAD(&rpipe->pipe_sel.si_note, kn, kn_selnext);
kn->kn_hook = (caddr_t)cpipe;
SLIST_INSERT_HEAD(&cpipe->pipe_sel.si_note, kn, kn_selnext);
return (0);
}
static void
filt_pipedetach(struct knote *kn)
{
struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
struct pipe *cpipe = (struct pipe *)kn->kn_hook;
SLIST_REMOVE(&rpipe->pipe_sel.si_note, kn, knote, kn_selnext);
SLIST_REMOVE(&cpipe->pipe_sel.si_note, kn, knote, kn_selnext);
}
/*ARGSUSED*/