VFS select: Correct reseting of socket FDs

When using multiple sockets, some of them could be incorrectly removed
from the fd_sets before passing these fd_sets forward to the socket
select function.

Closes https://github.com/espressif/esp-idf/issues/1987
This commit is contained in:
Roland Dobai
2018-05-24 10:02:24 +02:00
committed by bot
parent 5b88d90a6c
commit e6ae121f41
2 changed files with 33 additions and 9 deletions

View File

@@ -782,13 +782,15 @@ int esp_vfs_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds
continue;
}
if (!socket_select && is_socket_fd) {
// no socket_select found yet and the fd is for a socket so take a look
if ((readfds && FD_ISSET(fd, readfds)) ||
(writefds && FD_ISSET(fd, writefds)) ||
(errorfds && FD_ISSET(fd, errorfds))) {
const vfs_entry_t *vfs = s_vfs[vfs_index];
socket_select = vfs->vfs.socket_select;
if (is_socket_fd) {
if (!socket_select) {
// no socket_select found yet so take a look
if ((readfds && FD_ISSET(fd, readfds)) ||
(writefds && FD_ISSET(fd, writefds)) ||
(errorfds && FD_ISSET(fd, errorfds))) {
const vfs_entry_t *vfs = s_vfs[vfs_index];
socket_select = vfs->vfs.socket_select;
}
}
continue;
}