poll again; if fd is less than zero, it should set revents to zero, not POLLNVAL
This commit is contained in:
parent
abf8c8a13a
commit
d69228b5f7
@ -4777,8 +4777,7 @@
|
||||
* net/net_poll.c: When readahead data is availalbe, the network poll
|
||||
logic should set POLLIN (or POLLRDNORM), not POLLOUT. Max Holtzberg
|
||||
(2013-5-23)
|
||||
* fs/fs_poll.c: Actually, it should not ignore invlid descriptors, it
|
||||
should set the POLLNVAL event and return immediately (2013-5-23).
|
||||
* fs/fs_poll.c: Actually, it should also set revents == 0. (2013-5-23).
|
||||
* libc/misc/lib_slcdencode.c and lib_slcddecode.c: Add logic to marshal
|
||||
and serialized special SLCD intermixed with normal ASCII data (2013-5-23)
|
||||
* configs/stm32ldiscovery/src/stm32_lcd.c: STM32L-Discovery's segment LCD
|
||||
|
26
fs/fs_poll.c
26
fs/fs_poll.c
@ -166,28 +166,22 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds, sem_t *sem)
|
||||
/* Setup the poll descriptor */
|
||||
|
||||
fds[i].sem = sem;
|
||||
fds[i].revents = 0;
|
||||
fds[i].priv = NULL;
|
||||
|
||||
/* Check for invalid descriptors */
|
||||
/* Check for invalid descriptors. "If the value of fd is less than 0,
|
||||
* events shall be ignored, and revents shall be set to 0 in that entry
|
||||
* on return from poll()."
|
||||
*
|
||||
* NOTE: There is a potential problem here. If there is only one fd
|
||||
* and if it is negative, then poll will hang. From my reading of the
|
||||
* spec, that appears to be the correct behavior.
|
||||
*/
|
||||
|
||||
if (fds[i].fd < 0)
|
||||
{
|
||||
/* Set POLLNVAL to indicate the invalid fd member */
|
||||
|
||||
fds[i].revents = POLLNVAL;
|
||||
|
||||
/* And increment the semaphore so that poll will return
|
||||
* immediately (but with a successful return value).
|
||||
*/
|
||||
|
||||
sem_post(sem);
|
||||
}
|
||||
else
|
||||
if (fds[i].fd >= 0)
|
||||
{
|
||||
/* Set up the poll on this valid file descriptor */
|
||||
|
||||
fds[i].revents = 0;
|
||||
|
||||
ret = poll_fdsetup(fds[i].fd, &fds[i], true);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user