summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
diff options
context:
space:
mode:
authordyson <dyson@FreeBSD.org>1996-02-22 03:33:52 +0000
committerdyson <dyson@FreeBSD.org>1996-02-22 03:33:52 +0000
commit60f52cc4c159387974b7ca89b671e47d3f44ef62 (patch)
treef408eb957236b5cd8436410bcce603108f187852 /sys/kern/sys_pipe.c
parentc5181fe0d9df7a34fa3c95255ea660d64846d8ec (diff)
downloadFreeBSD-src-60f52cc4c159387974b7ca89b671e47d3f44ef62.zip
FreeBSD-src-60f52cc4c159387974b7ca89b671e47d3f44ef62.tar.gz
Fix a problem that select did not work with direct writes. Make
wakeup channels more consistant also.
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r--sys/kern/sys_pipe.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index b16311b..fb73f19 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.11 1996/02/11 22:09:50 dyson Exp $
+ * $Id: sys_pipe.c,v 1.12 1996/02/17 14:47:16 peter Exp $
*/
#ifndef OLD_PIPE
@@ -278,7 +278,7 @@ pipelock(cpipe, catch)
int error;
while (cpipe->pipe_state & PIPE_LOCK) {
cpipe->pipe_state |= PIPE_LWANT;
- if (error = tsleep( &cpipe->pipe_state,
+ if (error = tsleep( cpipe,
catch?(PRIBIO|PCATCH):PRIBIO, "pipelk", 0)) {
return error;
}
@@ -297,7 +297,7 @@ pipeunlock(cpipe)
cpipe->pipe_state &= ~PIPE_LOCK;
if (cpipe->pipe_state & PIPE_LWANT) {
cpipe->pipe_state &= ~PIPE_LWANT;
- wakeup(&cpipe->pipe_state);
+ wakeup(cpipe);
}
return;
}
@@ -430,6 +430,12 @@ pipe_read(fp, uio, cred)
} else {
break;
}
+
+ if (rpipe->pipe_state & PIPE_WANTW) {
+ rpipe->pipe_state &= ~PIPE_WANTW;
+ wakeup(rpipe);
+ }
+
rpipe->pipe_state |= PIPE_WANTR;
if (error = tsleep(rpipe, PRIBIO|PCATCH, "piperd", 0)) {
break;
@@ -473,7 +479,7 @@ pipe_read(fp, uio, cred)
}
}
- if ((rpipe->pipe_buffer.size - rpipe->pipe_buffer.cnt) > 0)
+ if ((rpipe->pipe_buffer.size - rpipe->pipe_buffer.cnt) > PIPE_BUF)
pipeselwakeup(rpipe);
return error;
@@ -638,7 +644,6 @@ retry:
error = tsleep(wpipe,
PRIBIO|PCATCH, "pipdwc", 0);
if (error || (wpipe->pipe_state & PIPE_EOF)) {
- wpipe->pipe_state &= ~PIPE_DIRECTW;
if (error == 0)
error = EPIPE;
goto error1;
@@ -858,7 +863,7 @@ pipewrite(wpipe, uio, nbio)
* We have something to offer,
* wake up select.
*/
- if (wpipe->pipe_buffer.cnt > 0)
+ if (wpipe->pipe_buffer.cnt)
pipeselwakeup(wpipe);
--wpipe->pipe_busy;
@@ -938,7 +943,8 @@ pipe_select(fp, which, p)
switch (which) {
case FREAD:
- if (rpipe->pipe_buffer.cnt > 0 ||
+ if ( (rpipe->pipe_state & PIPE_DIRECTW) ||
+ (rpipe->pipe_buffer.cnt > 0) ||
(rpipe->pipe_state & PIPE_EOF)) {
return (1);
}
@@ -949,7 +955,8 @@ pipe_select(fp, which, p)
case FWRITE:
if ((wpipe == NULL) ||
(wpipe->pipe_state & PIPE_EOF) ||
- ((wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) >= PIPE_BUF)) {
+ (((wpipe->pipe_state & PIPE_DIRECTW) == 0) &&
+ (wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) >= PIPE_BUF)) {
return (1);
}
selrecord(p, &wpipe->pipe_sel);
OpenPOWER on IntegriCloud