int poll(struct pollfd fds[], nfds_t nfds, int timeout)
{
- unsigned int i, ret;
+ int ret;
+ unsigned int i;
struct sock_net_file *file;
struct pollfd lwip_fds[nfds];
maxfd = 0;
for (i = 0; i < nfds; i++) {
if (readfds && FD_ISSET(i, readfds)) {
- maxfd = i;
file = sock_net_file_get(i);
if (PTRISERR(file)) {
LWIP_DEBUGF(SOCKETS_DEBUG,
SOCK_NET_SET_ERRNO(PTR2ERR(file));
goto EXIT;
}
+ if (maxfd < file->sock_fd)
+ maxfd = file->sock_fd;
FD_SET(file->sock_fd, &rd);
vfscore_put_file(&file->vfscore_file); /* release refcount */
}
if (writefds && FD_ISSET(i, writefds)) {
- maxfd = i;
file = sock_net_file_get(i);
if (PTRISERR(file)) {
LWIP_DEBUGF(SOCKETS_DEBUG,
SOCK_NET_SET_ERRNO(PTR2ERR(file));
goto EXIT;
}
+ if (maxfd < file->sock_fd)
+ maxfd = file->sock_fd;
FD_SET(file->sock_fd, &wr);
vfscore_put_file(&file->vfscore_file); /* release refcount */
}
if (exceptfds && FD_ISSET(i, exceptfds)) {
- maxfd = i;
file = sock_net_file_get(i);
if (PTRISERR(file)) {
LWIP_DEBUGF(SOCKETS_DEBUG,
SOCK_NET_SET_ERRNO(PTR2ERR(file));
goto EXIT;
}
+ if (maxfd < file->sock_fd)
+ maxfd = file->sock_fd;
FD_SET(file->sock_fd, &xc);
vfscore_put_file(&file->vfscore_file); /* release refcount */
}