Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions fs/vfs/fs_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,16 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
* read condition. POLLHUP will be reported when no more data will
* be available (such as when a connection is lost). In either
* case, the read() can then be performed without blocking.
*
* POLLERR is a read and a write condition too: a read() or a
* write() then returns at once, with an error. poll() reports
* POLLHUP and POLLERR even when they were not asked for, so set
* only the bits that the caller asked for.
*/

if (readfds)
if (readfds && (pollset[ndx].events & POLLIN) != 0)
{
if (pollset[ndx].revents & (POLLIN | POLLHUP))
if (pollset[ndx].revents & (POLLIN | POLLHUP | POLLERR))
{
FD_SET(pollset[ndx].fd, readfds);
ret++;
Expand All @@ -258,9 +263,9 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,

/* Check for write conditions */

if (writefds)
if (writefds && (pollset[ndx].events & POLLOUT) != 0)
{
if (pollset[ndx].revents & (POLLOUT | POLLHUP))
if (pollset[ndx].revents & (POLLOUT | POLLHUP | POLLERR))
{
FD_SET(pollset[ndx].fd, writefds);
ret++;
Expand Down
Loading