summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2020-12-30 17:02:33 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2020-12-30 17:02:33 +0000
commit1c79bb059c4c268f3153d8fb3005a1b572425826 (patch)
tree5e304890c861c6d4080ec3e986ce3e89950a33c2 /sys
parente9c44783356c18fa5e159d87f818fbaa0660073c (diff)
Set klist lock for pipes.
OK anton@, mpi@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/sys_pipe.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 5b4398f722f..f9bae89aa46 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.125 2020/12/25 12:59:52 visa Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.126 2020/12/30 17:02:32 visa Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -126,6 +126,7 @@ void pipe_iounlock(struct pipe *);
int pipe_iosleep(struct pipe *, const char *);
struct pipe_pair *pipe_pair_create(void);
+void pipe_pair_destroy(struct pipe_pair *);
/*
* The pipe system call for the DTYPE_PIPE type of pipes
@@ -853,7 +854,7 @@ pipe_destroy(struct pipe *cpipe)
rw_exit_write(cpipe->pipe_lock);
if (ppipe == NULL)
- pool_put(&pipe_pair_pool, cpipe->pipe_pair);
+ pipe_pair_destroy(cpipe->pipe_pair);
}
/*
@@ -913,9 +914,7 @@ filt_pipedetach(struct knote *kn)
{
struct pipe *cpipe = kn->kn_hook;
- rw_enter_write(cpipe->pipe_lock);
- klist_remove_locked(&cpipe->pipe_sel.si_note, kn);
- rw_exit_write(cpipe->pipe_lock);
+ klist_remove(&cpipe->pipe_sel.si_note, kn);
}
int
@@ -997,6 +996,9 @@ pipe_pair_create(void)
pp->pp_wpipe.pipe_lock = &pp->pp_lock;
pp->pp_rpipe.pipe_lock = &pp->pp_lock;
+ klist_init_rwlock(&pp->pp_wpipe.pipe_sel.si_note, &pp->pp_lock);
+ klist_init_rwlock(&pp->pp_rpipe.pipe_sel.si_note, &pp->pp_lock);
+
if (pipe_create(&pp->pp_wpipe) || pipe_create(&pp->pp_rpipe))
goto err;
return (pp);
@@ -1005,3 +1007,11 @@ err:
pipe_destroy(&pp->pp_rpipe);
return (NULL);
}
+
+void
+pipe_pair_destroy(struct pipe_pair *pp)
+{
+ klist_free(&pp->pp_wpipe.pipe_sel.si_note);
+ klist_free(&pp->pp_rpipe.pipe_sel.si_note);
+ pool_put(&pipe_pair_pool, pp);
+}