summaryrefslogtreecommitdiff
path: root/nuttx/fs/fs_poll.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/fs/fs_poll.c')
-rw-r--r--nuttx/fs/fs_poll.c26
1 files changed, 10 insertions, 16 deletions
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)
{