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.
This commit is contained in:
parent
61a0da1de5
commit
e22b0bf4b8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=113789
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user