aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2003-04-21 05:58:51 +0000
committerWarner Losh <imp@FreeBSD.org>2003-04-21 05:58:51 +0000
commite22b0bf4b8d2885efa0dc4c1c5127de3008f7cd5 (patch)
tree99bc8b116945a7fa927cae614e40521d1cd00148 /sys/kern/subr_bus.c
parent61a0da1de58423828ee7cdfff28b6d19c43af56f (diff)
downloadsrc-e22b0bf4b8d2885efa0dc4c1c5127de3008f7cd5.tar.gz
src-e22b0bf4b8d2885efa0dc4c1c5127de3008f7cd5.zip
Fix /dev/devctl's implementation of poll. We should only be setting
the poll bits when there's actually something in the queue. Otherwise, select always returned '2' when there were no items to be read, and '3' when there were. This would preclude being able to read in a threaded (libc_r) program, as well as checking to see if there were pending events or not.
Notes
Notes: svn path=/head/; revision=113789
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r--sys/kern/subr_bus.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 6c5955858d40..ecb1c7a05a78 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -353,21 +353,15 @@ devpoll(dev_t dev, int events, d_thread_t *td)
{
int revents = 0;
- if (events & (POLLIN | POLLRDNORM))
- revents |= events & (POLLIN | POLLRDNORM);
-
- if (events & (POLLOUT | POLLWRNORM))
- revents |= events & (POLLOUT | POLLWRNORM);
-
mtx_lock(&devsoftc.mtx);
- if (events & POLLRDBAND)
+ if (events & (POLLIN | POLLRDNORM)) {
if (!TAILQ_EMPTY(&devsoftc.devq))
- revents |= POLLRDBAND;
+ revents = events & (POLLIN | POLLRDNORM);
+ else
+ selrecord(td, &devsoftc.sel);
+ }
mtx_unlock(&devsoftc.mtx);
- if (revents == 0)
- selrecord(td, &devsoftc.sel);
-
return (revents);
}