Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/sys_pipe.c
Show First 20 Lines • Show All 807 Lines • ▼ Show 20 Lines | #endif | ||||
* Handle non-blocking mode operation or | * Handle non-blocking mode operation or | ||||
* wait for more data. | * wait for more data. | ||||
*/ | */ | ||||
if (fp->f_flag & FNONBLOCK) { | if (fp->f_flag & FNONBLOCK) { | ||||
error = EAGAIN; | error = EAGAIN; | ||||
} else { | } else { | ||||
rpipe->pipe_state |= PIPE_WANTR; | rpipe->pipe_state |= PIPE_WANTR; | ||||
if ((error = msleep(rpipe, PIPE_MTX(rpipe), | if ((error = msleep(rpipe, PIPE_MTX(rpipe), | ||||
PRIBIO | PCATCH, | PRIBIO | PCATCH | PUSERW, | ||||
"piperd", 0)) == 0) | "piperd", 0)) == 0) | ||||
error = pipelock(rpipe, 1); | error = pipelock(rpipe, 1); | ||||
} | } | ||||
if (error) | if (error) | ||||
goto unlocked_error; | goto unlocked_error; | ||||
} | } | ||||
} | } | ||||
#ifdef MAC | #ifdef MAC | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | if (wpipe->pipe_state & PIPE_DIRECTW) { | ||||
if (wpipe->pipe_state & PIPE_WANTR) { | if (wpipe->pipe_state & PIPE_WANTR) { | ||||
wpipe->pipe_state &= ~PIPE_WANTR; | wpipe->pipe_state &= ~PIPE_WANTR; | ||||
wakeup(wpipe); | wakeup(wpipe); | ||||
} | } | ||||
pipeselwakeup(wpipe); | pipeselwakeup(wpipe); | ||||
wpipe->pipe_state |= PIPE_WANTW; | wpipe->pipe_state |= PIPE_WANTW; | ||||
pipeunlock(wpipe); | pipeunlock(wpipe); | ||||
error = msleep(wpipe, PIPE_MTX(wpipe), | error = msleep(wpipe, PIPE_MTX(wpipe), | ||||
PRIBIO | PCATCH, "pipdww", 0); | PRIBIO | PCATCH | PUSERW, "pipdww", 0); | ||||
if (error) | if (error) | ||||
goto error1; | goto error1; | ||||
else | else | ||||
goto retry; | goto retry; | ||||
} | } | ||||
if (wpipe->pipe_buffer.cnt > 0) { | if (wpipe->pipe_buffer.cnt > 0) { | ||||
if (wpipe->pipe_state & PIPE_WANTR) { | if (wpipe->pipe_state & PIPE_WANTR) { | ||||
wpipe->pipe_state &= ~PIPE_WANTR; | wpipe->pipe_state &= ~PIPE_WANTR; | ||||
wakeup(wpipe); | wakeup(wpipe); | ||||
} | } | ||||
pipeselwakeup(wpipe); | pipeselwakeup(wpipe); | ||||
wpipe->pipe_state |= PIPE_WANTW; | wpipe->pipe_state |= PIPE_WANTW; | ||||
pipeunlock(wpipe); | pipeunlock(wpipe); | ||||
error = msleep(wpipe, PIPE_MTX(wpipe), | error = msleep(wpipe, PIPE_MTX(wpipe), | ||||
PRIBIO | PCATCH, "pipdwc", 0); | PRIBIO | PCATCH | PUSERW, "pipdwc", 0); | ||||
if (error) | if (error) | ||||
goto error1; | goto error1; | ||||
else | else | ||||
goto retry; | goto retry; | ||||
} | } | ||||
error = pipe_build_write_buffer(wpipe, uio); | error = pipe_build_write_buffer(wpipe, uio); | ||||
if (error) { | if (error) { | ||||
pipeunlock(wpipe); | pipeunlock(wpipe); | ||||
goto error1; | goto error1; | ||||
} | } | ||||
while (wpipe->pipe_pages.cnt != 0 && | while (wpipe->pipe_pages.cnt != 0 && | ||||
(wpipe->pipe_state & PIPE_EOF) == 0) { | (wpipe->pipe_state & PIPE_EOF) == 0) { | ||||
if (wpipe->pipe_state & PIPE_WANTR) { | if (wpipe->pipe_state & PIPE_WANTR) { | ||||
wpipe->pipe_state &= ~PIPE_WANTR; | wpipe->pipe_state &= ~PIPE_WANTR; | ||||
wakeup(wpipe); | wakeup(wpipe); | ||||
} | } | ||||
pipeselwakeup(wpipe); | pipeselwakeup(wpipe); | ||||
wpipe->pipe_state |= PIPE_WANTW; | wpipe->pipe_state |= PIPE_WANTW; | ||||
pipeunlock(wpipe); | pipeunlock(wpipe); | ||||
error = msleep(wpipe, PIPE_MTX(wpipe), PRIBIO | PCATCH, | error = msleep(wpipe, PIPE_MTX(wpipe), PRIBIO | PCATCH | PUSERW, | ||||
"pipdwt", 0); | "pipdwt", 0); | ||||
pipelock(wpipe, 0); | pipelock(wpipe, 0); | ||||
if (error != 0) | if (error != 0) | ||||
break; | break; | ||||
} | } | ||||
if ((wpipe->pipe_state & PIPE_EOF) != 0) { | if ((wpipe->pipe_state & PIPE_EOF) != 0) { | ||||
wpipe->pipe_pages.cnt = 0; | wpipe->pipe_pages.cnt = 0; | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | #endif | ||||
if (wpipe->pipe_pages.cnt != 0) { | if (wpipe->pipe_pages.cnt != 0) { | ||||
if (wpipe->pipe_state & PIPE_WANTR) { | if (wpipe->pipe_state & PIPE_WANTR) { | ||||
wpipe->pipe_state &= ~PIPE_WANTR; | wpipe->pipe_state &= ~PIPE_WANTR; | ||||
wakeup(wpipe); | wakeup(wpipe); | ||||
} | } | ||||
pipeselwakeup(wpipe); | pipeselwakeup(wpipe); | ||||
wpipe->pipe_state |= PIPE_WANTW; | wpipe->pipe_state |= PIPE_WANTW; | ||||
pipeunlock(wpipe); | pipeunlock(wpipe); | ||||
error = msleep(wpipe, PIPE_MTX(rpipe), PRIBIO | PCATCH, | error = msleep(wpipe, PIPE_MTX(rpipe), PRIBIO | PCATCH | PUSERW, | ||||
"pipbww", 0); | "pipbww", 0); | ||||
if (error) | if (error) | ||||
break; | break; | ||||
else | else | ||||
continue; | continue; | ||||
} | } | ||||
space = wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt; | space = wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt; | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if (space > 0) { | ||||
* We have no more space and have something to offer, | * We have no more space and have something to offer, | ||||
* wake up select/poll. | * wake up select/poll. | ||||
*/ | */ | ||||
pipeselwakeup(wpipe); | pipeselwakeup(wpipe); | ||||
wpipe->pipe_state |= PIPE_WANTW; | wpipe->pipe_state |= PIPE_WANTW; | ||||
pipeunlock(wpipe); | pipeunlock(wpipe); | ||||
error = msleep(wpipe, PIPE_MTX(rpipe), | error = msleep(wpipe, PIPE_MTX(rpipe), | ||||
PRIBIO | PCATCH, "pipewr", 0); | PRIBIO | PCATCH | PUSERW, "pipewr", 0); | ||||
if (error != 0) | if (error != 0) | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
pipelock(wpipe, 0); | pipelock(wpipe, 0); | ||||
--wpipe->pipe_busy; | --wpipe->pipe_busy; | ||||
▲ Show 20 Lines • Show All 530 Lines • Show Last 20 Lines |