summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2003-04-21 05:58:51 +0000
committerimp <imp@FreeBSD.org>2003-04-21 05:58:51 +0000
commitcf3cf85267793e75562a6705ade86e2e2f2ffd46 (patch)
tree99bc8b116945a7fa927cae614e40521d1cd00148 /sys/kern/subr_bus.c
parent68750c77958aea54992841f17a2167facbff033f (diff)
downloadFreeBSD-src-cf3cf85267793e75562a6705ade86e2e2f2ffd46.zip
FreeBSD-src-cf3cf85267793e75562a6705ade86e2e2f2ffd46.tar.gz
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.
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 6c59558..ecb1c7a 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);
}
OpenPOWER on IntegriCloud