Date: Wed, 8 Jul 2009 10:21:52 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r195444 - head/sys/kern Message-ID: <200907081021.n68ALqsa045650@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Wed Jul 8 10:21:52 2009 New Revision: 195444 URL: http://svn.freebsd.org/changeset/base/195444 Log: Fix regressions in return events of poll() on TTYs. As pointed out, POLLHUP should be generated, even if it hasn't been specified on input. It is also not allowed to return both POLLOUT and POLLHUP at the same time. Reported by: jilles Approved by: re (kib) Modified: head/sys/kern/tty.c head/sys/kern/tty_pts.c Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Wed Jul 8 10:16:16 2009 (r195443) +++ head/sys/kern/tty.c Wed Jul 8 10:21:52 2009 (r195444) @@ -536,25 +536,23 @@ ttydev_poll(struct cdev *dev, int events int error, revents = 0; error = ttydev_enter(tp); - if (error) { - /* Don't return the error here, but the event mask. */ - return (events & - (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM)); - } + if (error) + return ((events & (POLLIN|POLLRDNORM)) | POLLHUP); if (events & (POLLIN|POLLRDNORM)) { /* See if we can read something. */ if (ttydisc_read_poll(tp) > 0) revents |= events & (POLLIN|POLLRDNORM); } - if (events & (POLLOUT|POLLWRNORM)) { + + if (tp->t_flags & TF_ZOMBIE) { + /* Hangup flag on zombie state. */ + revents |= POLLHUP; + } else if (events & (POLLOUT|POLLWRNORM)) { /* See if we can write something. */ if (ttydisc_write_poll(tp) > 0) revents |= events & (POLLOUT|POLLWRNORM); } - if (tp->t_flags & TF_ZOMBIE) - /* Hangup flag on zombie state. */ - revents |= events & POLLHUP; if (revents == 0) { if (events & (POLLIN|POLLRDNORM)) Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Wed Jul 8 10:16:16 2009 (r195443) +++ head/sys/kern/tty_pts.c Wed Jul 8 10:21:52 2009 (r195444) @@ -409,8 +409,7 @@ ptsdev_poll(struct file *fp, int events, if (psc->pts_flags & PTS_FINISHED) { /* Slave device is not opened. */ tty_unlock(tp); - return (events & - (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM)); + return ((events & (POLLIN|POLLRDNORM)) | POLLHUP); } if (events & (POLLIN|POLLRDNORM)) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907081021.n68ALqsa045650>