summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-05-23 15:41:15 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-05-23 15:41:15 -0600
commitb4c74bf206e5864dbbff8a1c6d59d1ce9893752d (patch)
treefa6ccf08fef4d153ca45ca5dcedffae84001e064 /nuttx
parentdfaa61731b87c0685c17f41a95a2e758deca80a7 (diff)
downloadpx4-nuttx-b4c74bf206e5864dbbff8a1c6d59d1ce9893752d.tar.gz
px4-nuttx-b4c74bf206e5864dbbff8a1c6d59d1ce9893752d.tar.bz2
px4-nuttx-b4c74bf206e5864dbbff8a1c6d59d1ce9893752d.zip
poll again; if fd is less than zero, it should set revents to zero, not POLLNVAL
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/ChangeLog3
-rw-r--r--nuttx/fs/fs_poll.c26
2 files changed, 11 insertions, 18 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index e33660231..ba34d1201 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -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
diff --git a/nuttx/fs/fs_poll.c b/nuttx/fs/fs_poll.c
index b6a09b644..52d7f94a8 100644
--- a/nuttx/fs/fs_poll.c
+++ b/nuttx/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 */
-
- 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).
- */
+ /* 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.
+ */
- 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)
{