Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/sys_pipe.c
Show First 20 Lines • Show All 1,735 Lines • ▼ Show 20 Lines | filt_piperead(struct knote *kn, long hint) | ||||
return ret; | return ret; | ||||
} | } | ||||
/*ARGSUSED*/ | /*ARGSUSED*/ | ||||
static int | static int | ||||
filt_pipewrite(struct knote *kn, long hint) | filt_pipewrite(struct knote *kn, long hint) | ||||
{ | { | ||||
struct pipe *wpipe; | struct pipe *wpipe; | ||||
/* | |||||
* If this end of the pipe is closed, the knote was removed from the | |||||
* knlist and the list lock (i.e., the pipe lock) is therefore not held. | |||||
*/ | |||||
wpipe = kn->kn_hook; | wpipe = kn->kn_hook; | ||||
PIPE_LOCK_ASSERT(wpipe, MA_OWNED); | |||||
if (wpipe->pipe_present != PIPE_ACTIVE || | if (wpipe->pipe_present != PIPE_ACTIVE || | ||||
(wpipe->pipe_state & PIPE_EOF)) { | (wpipe->pipe_state & PIPE_EOF)) { | ||||
kn->kn_data = 0; | kn->kn_data = 0; | ||||
kn->kn_flags |= EV_EOF; | kn->kn_flags |= EV_EOF; | ||||
return (1); | return (1); | ||||
} | } | ||||
PIPE_LOCK_ASSERT(wpipe, MA_OWNED); | |||||
kn->kn_data = (wpipe->pipe_buffer.size > 0) ? | kn->kn_data = (wpipe->pipe_buffer.size > 0) ? | ||||
(wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) : PIPE_BUF; | (wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) : PIPE_BUF; | ||||
if (wpipe->pipe_state & PIPE_DIRECTW) | if (wpipe->pipe_state & PIPE_DIRECTW) | ||||
kn->kn_data = 0; | kn->kn_data = 0; | ||||
return (kn->kn_data >= PIPE_BUF); | return (kn->kn_data >= PIPE_BUF); | ||||
} | } | ||||
Show All 12 Lines |