summaryrefslogtreecommitdiff
path: root/sys/kern/sys_pipe.c
diff options
context:
space:
mode:
authoranton <anton@cvs.openbsd.org>2020-02-16 07:59:09 +0000
committeranton <anton@cvs.openbsd.org>2020-02-16 07:59:09 +0000
commit40f0cce663f7c2a414b2131266b7d74d9bf645cd (patch)
tree7c0a1324015caba5fdf7de7bdfb965269b301024 /sys/kern/sys_pipe.c
parent264d1feb4d3cfdd41d4703f8afbd11b23ce6b5d6 (diff)
Unconditionally acquiring a write lock in pipe_ioctl() is quite
excessive as only one command actually modifies the pipe. The sigio subsystem is already internally protected using its own lock. This is similar to what soo_ioctl() already does. ok mpi@ visa@
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r--sys/kern/sys_pipe.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index ddc41bed9b6..9a4cb6b3636 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.116 2020/02/14 14:32:44 mpi Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.117 2020/02/16 07:59:08 anton Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -683,23 +683,25 @@ pipe_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p)
struct pipe *mpipe = fp->f_data;
int error = 0;
- rw_enter_write(mpipe->pipe_lock);
-
switch (cmd) {
case FIONBIO:
break;
case FIOASYNC:
+ rw_enter_write(mpipe->pipe_lock);
if (*(int *)data) {
mpipe->pipe_state |= PIPE_ASYNC;
} else {
mpipe->pipe_state &= ~PIPE_ASYNC;
}
+ rw_exit_write(mpipe->pipe_lock);
break;
case FIONREAD:
+ rw_enter_read(mpipe->pipe_lock);
*(int *)data = mpipe->pipe_buffer.cnt;
+ rw_exit_read(mpipe->pipe_lock);
break;
case FIOSETOWN:
@@ -718,8 +720,6 @@ pipe_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p)
error = ENOTTY;
}
- rw_exit_write(mpipe->pipe_lock);
-
return (error);
}