int poll(struct pollfd fds[], nfds_t nfds, int timeout)
{
- unsigned int i;
+ unsigned int i, ret;
struct sock_net_file *file;
struct pollfd lwip_fds[nfds];
if (PTRISERR(file)) {
LWIP_DEBUGF(SOCKETS_DEBUG,
("failed to identify socket descriptor\n"));
+ ret = -1;
/* Setting the errno */
SOCK_NET_SET_ERRNO(PTR2ERR(file));
- return -1;
+ goto EXIT;
}
lwip_fds[i].fd = file->sock_fd;
lwip_fds[i].events = fds[i].events;
+ vfscore_put_file(&file->vfscore_file); /* release refcount */
}
}
- lwip_poll(lwip_fds, nfds, timeout);
+ ret = lwip_poll(lwip_fds, nfds, timeout);
+ if (ret < 0)
+ goto EXIT;
for (i = 0; i < nfds; i++) {
if (fds[i].fd < 0)
else
fds[i].revents = lwip_fds[i].revents;
}
- return 0;
+
+EXIT:
+ return ret;
}
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
goto EXIT;
}
FD_SET(file->sock_fd, &rd);
+ vfscore_put_file(&file->vfscore_file); /* release refcount */
}
if (writefds && FD_ISSET(i, writefds)) {
maxfd = i;
goto EXIT;
}
FD_SET(file->sock_fd, &wr);
+ vfscore_put_file(&file->vfscore_file); /* release refcount */
}
if (exceptfds && FD_ISSET(i, exceptfds)) {
maxfd = i;
goto EXIT;
}
FD_SET(file->sock_fd, &xc);
+ vfscore_put_file(&file->vfscore_file); /* release refcount */
}
}
ret = lwip_select(maxfd+1, &rd, &wr, &xc, timeout);
if (ret < 0)
- return ret;
+ goto EXIT;
/* translate back from lwIP socket fds to public (vfscore) fds.
* But there's no way to go from lwIP to vfscore, so iterate over
file = sock_net_file_get(i);
if (!FD_ISSET(file->sock_fd, &rd))
FD_CLR(i, readfds);
+ vfscore_put_file(&file->vfscore_file); /* release refcount */
}
if (writefds && FD_ISSET(i, writefds)) {
/* This lookup can't fail, or it would already have
file = sock_net_file_get(i);
if (!FD_ISSET(file->sock_fd, &wr))
FD_CLR(i, writefds);
+ vfscore_put_file(&file->vfscore_file); /* release refcount */
}
if (exceptfds && FD_ISSET(i, exceptfds)) {
/* This lookup can't fail, or it would already have
file = sock_net_file_get(i);
if (!FD_ISSET(file->sock_fd, &xc))
FD_CLR(i, exceptfds);
+ vfscore_put_file(&file->vfscore_file); /* release refcount */
}
}
- return 0;
EXIT:
return ret;