diff options
| author | 2020-02-16 07:59:08 +0000 | |
|---|---|---|
| committer | 2020-02-16 07:59:08 +0000 | |
| commit | 42e31c228413cc665b52f53adf7450715f9bcdcd (patch) | |
| tree | ca19394e386979b82f569b45e06da408c82d0acb /sys/kern/sys_pipe.c | |
| parent | Cope with latest changes to the ps_flags field of struct process which (diff) | |
| download | wireguard-openbsd-42e31c228413cc665b52f53adf7450715f9bcdcd.tar.xz wireguard-openbsd-42e31c228413cc665b52f53adf7450715f9bcdcd.zip | |
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.c | 10 |
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); } |
