diff options
author | dyson <dyson@FreeBSD.org> | 1996-02-07 06:41:56 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1996-02-07 06:41:56 +0000 |
commit | 88532580c7fb418950f8b611c58d78ffe647da18 (patch) | |
tree | 9efbc7cd02b3b63573e75b6912f5ff9c19975922 /sys/kern/sys_pipe.c | |
parent | 3a72155781cd0f4a855aca98e03ad19c93fe0948 (diff) | |
download | FreeBSD-src-88532580c7fb418950f8b611c58d78ffe647da18.zip FreeBSD-src-88532580c7fb418950f8b611c58d78ffe647da18.tar.gz |
Apparent fix for a pipe hang problem.
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r-- | sys/kern/sys_pipe.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 2d26850..3e627f7 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -18,7 +18,7 @@ * 5. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: sys_pipe.c,v 1.6 1996/02/04 22:09:05 dyson Exp $ + * $Id: sys_pipe.c,v 1.8 1996/02/05 05:50:34 dyson Exp $ */ #ifndef OLD_PIPE @@ -585,15 +585,25 @@ pipe_direct_write(wpipe, uio) struct uio *uio; { int error; +retry: while (wpipe->pipe_state & PIPE_DIRECTW) { + if ( wpipe->pipe_state & PIPE_WANTR) { + wpipe->pipe_state &= ~PIPE_WANTR; + wakeup(wpipe); + } + error = tsleep(wpipe, PRIBIO|PCATCH, "pipdww", 0); if (error || (wpipe->pipe_state & PIPE_EOF)) goto error1; } wpipe->pipe_map.cnt = 0; /* transfer not ready yet */ - wpipe->pipe_state |= PIPE_DIRECTW; - while (wpipe->pipe_buffer.cnt > 0) { + if (wpipe->pipe_buffer.cnt > 0) { + if ( wpipe->pipe_state & PIPE_WANTR) { + wpipe->pipe_state &= ~PIPE_WANTR; + wakeup(wpipe); + } + error = tsleep(wpipe, PRIBIO|PCATCH, "pipdwc", 0); if (error || (wpipe->pipe_state & PIPE_EOF)) { @@ -602,8 +612,11 @@ pipe_direct_write(wpipe, uio) error = EPIPE; goto error1; } + goto retry; } + wpipe->pipe_state |= PIPE_DIRECTW; + error = pipe_build_write_buffer(wpipe, uio); if (error) { wpipe->pipe_state &= ~PIPE_DIRECTW; |