summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-07-07 09:43:44 +0000
committerkib <kib@FreeBSD.org>2009-07-07 09:43:44 +0000
commit6c6bda868d12c26d6e0fe65000f5f3c00d0112d7 (patch)
treefa963c164b557f57ea4c0183ad1527b57d286d89 /sys/kern/sys_pipe.c
parentc59ed917ab6692f0644e851cf9485261d36789fa (diff)
downloadFreeBSD-src-6c6bda868d12c26d6e0fe65000f5f3c00d0112d7.zip
FreeBSD-src-6c6bda868d12c26d6e0fe65000f5f3c00d0112d7.tar.gz
Fix poll(2) and select(2) for named pipes to return "ready for read"
when all writers, observed by reader, exited. Use writer generation counter for fifo, and store the snapshot of the fifo generation in the f_seqcount field of struct file, that is otherwise unused for fifos. Set FreeBSD-undocumented POLLINIGNEOF flag only when file f_seqcount is equal to fifo' fi_wgen, and revert r89376. Fix POLLINIGNEOF for sockets and pipes, and return POLLHUP for them. Note that the patch does not fix not returning POLLHUP for fifos. PR: kern/94772 Submitted by: bde (original version) Reviewed by: rwatson, jilles Approved by: re (kensmith) MFC after: 6 weeks (might be)
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r--sys/kern/sys_pipe.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 45dc0f6..ce20d28 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1353,8 +1353,7 @@ pipe_poll(fp, events, active_cred, td)
#endif
if (events & (POLLIN | POLLRDNORM))
if ((rpipe->pipe_state & PIPE_DIRECTW) ||
- (rpipe->pipe_buffer.cnt > 0) ||
- (rpipe->pipe_state & PIPE_EOF))
+ (rpipe->pipe_buffer.cnt > 0))
revents |= events & (POLLIN | POLLRDNORM);
if (events & (POLLOUT | POLLWRNORM))
@@ -1364,10 +1363,14 @@ pipe_poll(fp, events, active_cred, td)
(wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) >= PIPE_BUF))
revents |= events & (POLLOUT | POLLWRNORM);
- if ((rpipe->pipe_state & PIPE_EOF) ||
- wpipe->pipe_present != PIPE_ACTIVE ||
- (wpipe->pipe_state & PIPE_EOF))
- revents |= POLLHUP;
+ if ((events & POLLINIGNEOF) == 0) {
+ if (rpipe->pipe_state & PIPE_EOF) {
+ revents |= (events & (POLLIN | POLLRDNORM));
+ if (wpipe->pipe_present != PIPE_ACTIVE ||
+ (wpipe->pipe_state & PIPE_EOF))
+ revents |= POLLHUP;
+ }
+ }
if (revents == 0) {
if (events & (POLLIN | POLLRDNORM)) {
OpenPOWER on IntegriCloud