poll should ignore invalid file descriptors
This commit is contained in:
parent
eb35cbf558
commit
16d04c7aa7
@ -4772,4 +4772,6 @@
|
|||||||
correct usage of the socket API. Contributed by Max Holtzberg (2013-5-22).
|
correct usage of the socket API. Contributed by Max Holtzberg (2013-5-22).
|
||||||
* configs/stm32ldiscovery/src/stm32_lcd.c: Framework for support of the
|
* configs/stm32ldiscovery/src/stm32_lcd.c: Framework for support of the
|
||||||
STM32L-Discovery's segment LCD (2013-5-22).
|
STM32L-Discovery's segment LCD (2013-5-22).
|
||||||
|
* fs/fs_poll.c: Poll setup/teardown logic should ignore invalid (i.e.,
|
||||||
|
negative) file descriptors. Max Holtzberg (2013-5-23).
|
||||||
|
|
||||||
|
14
fs/fs_poll.c
14
fs/fs_poll.c
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/fs_poll.c
|
* fs/fs_poll.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -140,6 +140,7 @@ static int poll_fdsetup(int fd, FAR struct pollfd *fds, bool setup)
|
|||||||
|
|
||||||
ret = (int)inode->u.i_ops->poll(this_file, fds, setup);
|
ret = (int)inode->u.i_ops->poll(this_file, fds, setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -161,6 +162,10 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds, sem_t *sem)
|
|||||||
/* Process each descriptor in the list */
|
/* Process each descriptor in the list */
|
||||||
|
|
||||||
for (i = 0; i < nfds; i++)
|
for (i = 0; i < nfds; i++)
|
||||||
|
{
|
||||||
|
/* Ignore negative descriptors */
|
||||||
|
|
||||||
|
if (fds[i].fd >= 0)
|
||||||
{
|
{
|
||||||
/* Setup the poll descriptor */
|
/* Setup the poll descriptor */
|
||||||
|
|
||||||
@ -176,6 +181,8 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds, sem_t *sem)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -200,6 +207,10 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count)
|
|||||||
|
|
||||||
*count = 0;
|
*count = 0;
|
||||||
for (i = 0; i < nfds; i++)
|
for (i = 0; i < nfds; i++)
|
||||||
|
{
|
||||||
|
/* Ignore negative descriptors */
|
||||||
|
|
||||||
|
if (fds[i].fd >= 0)
|
||||||
{
|
{
|
||||||
/* Teardown the poll */
|
/* Teardown the poll */
|
||||||
|
|
||||||
@ -220,6 +231,7 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count)
|
|||||||
|
|
||||||
fds[i].sem = NULL;
|
fds[i].sem = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user