1
1

poll: Check if maxfd has been set.

Этот коммит содержится в:
Andreas Schneider 2010-06-20 21:16:29 +02:00
родитель c8d978f4e9
Коммит 6f9fea7fd5

Просмотреть файл

@ -135,7 +135,7 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
FD_ZERO (&exceptfds); FD_ZERO (&exceptfds);
/* compute fd_sets and find largest descriptor */ /* compute fd_sets and find largest descriptor */
for (max_fd = 0, i = 0; i < nfds; i++) { for (rc = -1; max_fd = 0, i = 0; i < nfds; i++) {
if (fds[i].fd == SSH_INVALID_SOCKET) { if (fds[i].fd == SSH_INVALID_SOCKET) {
continue; continue;
} }
@ -154,10 +154,11 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
POLLRDNORM | POLLRDBAND | POLLRDNORM | POLLRDBAND |
POLLWRNORM | POLLWRBAND))) { POLLWRNORM | POLLWRBAND))) {
max_fd = fds[i].fd; max_fd = fds[i].fd;
rc = 0;
} }
} }
if (max_fd == SSH_INVALID_SOCKET) { if (max_fd == SSH_INVALID_SOCKET || rc = -1) {
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }