aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJohn Dyson <dyson@FreeBSD.org>1996-03-17 04:52:10 +0000
committerJohn Dyson <dyson@FreeBSD.org>1996-03-17 04:52:10 +0000
commit7fe9c39beaf9d9a50f7d394a9ca3d0cf25a32acc (patch)
tree0a4097e119a743d690584d1a03af8148cf9544e5 /sys
parentfe63158271a58cbe68e3225244489c7d81133806 (diff)
downloadsrc-7fe9c39beaf9d9a50f7d394a9ca3d0cf25a32acc.tar.gz
src-7fe9c39beaf9d9a50f7d394a9ca3d0cf25a32acc.zip
Yet another fix from BDE for the new pipe code. This fixes a potential
deadlock due to mismanagement of busy counters. Reviewed by: dyson Submitted by: bde
Notes
Notes: svn path=/head/; revision=14644
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/sys_pipe.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index fb73f19c2d44..9bc3bf3e23b4 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -16,7 +16,7 @@
* 4. Modifications may be freely made to this file if the above conditions
* are met.
*
- * $Id: sys_pipe.c,v 1.12 1996/02/17 14:47:16 peter Exp $
+ * $Id: sys_pipe.c,v 1.13 1996/02/22 03:33:52 dyson Exp $
*/
#ifndef OLD_PIPE
@@ -759,13 +759,12 @@ pipewrite(wpipe, uio, nbio)
}
space = wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt;
+
+ /* Writes of size <= PIPE_BUF must be atomic. */
+ /* XXX perhaps they need to be contiguous to be atomic? */
if ((space < uio->uio_resid) && (orig_resid <= PIPE_BUF))
space = 0;
- /*
- * We must afford contiguous writes on buffers of size
- * PIPE_BUF or less.
- */
if (space > 0) {
int size = wpipe->pipe_buffer.size - wpipe->pipe_buffer.in;
if (size > space)
@@ -831,6 +830,7 @@ pipewrite(wpipe, uio, nbio)
}
}
+ --wpipe->pipe_busy;
if ((wpipe->pipe_busy == 0) &&
(wpipe->pipe_state & PIPE_WANT)) {
wpipe->pipe_state &= ~(PIPE_WANT|PIPE_WANTR);
@@ -866,7 +866,6 @@ pipewrite(wpipe, uio, nbio)
if (wpipe->pipe_buffer.cnt)
pipeselwakeup(wpipe);
- --wpipe->pipe_busy;
return error;
}