Questions on drivers returning POLLNVAL
Hello, All,
I seem to be problems with select() when I return POLLNVAL from the poll() entry point of my driver.
For more context, I am attaching the following snippet of code from fs/select.c (do_select). I am looking at 2.4.22
if (file) {
mask = DEFAULT_POLLMASK;
if (file->f_op && file->f_op->poll)
mask = file->f_op->poll(file, wait);
fput(file);
}
if ((mask & POLLIN_SET) && ISSET(bit,
__IN(fds,off))) {
SET(bit, __RES_IN(fds,off));
retval++;
wait = NULL;
}
if ((mask & POLLOUT_SET) && ISSET(bit,
__OUT(fds,off)))
{
SET(bit, __RES_OUT(fds,off));
retval++;
wait = NULL;
}
if ((mask & POLLEX_SET) && ISSET(bit,
__EX(fds,off))) {
SET(bit, __RES_EX(fds,off));
retval++;
wait = NULL;
}
}
wait = NULL;
if (retval || !__timeout || signal_pending(current))
break;
if(table.error) {
retval = table.error;
break;
}
__timeout = schedule_timeout(__timeout);When I return POLLNVAL from my driver, the user set the select timeout set to NULL, I get caught up in schedule_timeout.
when I pass NULL for timeout from userland, in the kernel, I see __timeout set to 2147483647. I have not investigated this yet. Hence I fail the two checks for breaking out of the loop and get stuck in schedule_timeout.
Am I expected to set POLLNVAL in table->error passed to the poll() entry point explicitly?
Thanks,
Balbir