diff options
author | Andreas Schneider <asn@cynapses.org> | 2010-06-24 09:17:39 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cynapses.org> | 2010-06-24 09:17:39 +0200 |
commit | e50752a925785b217a635491bc02dc24fbe5192d (patch) | |
tree | e22a05b5b8d346b13a7f4af3d7e52ff76db64e3f | |
parent | fd45c1b36b4ccb9247af1cf69a07fda1152f6c72 (diff) | |
download | libssh-e50752a925785b217a635491bc02dc24fbe5192d.tar.gz libssh-e50752a925785b217a635491bc02dc24fbe5192d.tar.xz libssh-e50752a925785b217a635491bc02dc24fbe5192d.zip |
poll: Another attempt to get bsd_poll() working correctly.
-rw-r--r-- | libssh/poll.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libssh/poll.c b/libssh/poll.c index b565ed8c..70d42fda 100644 --- a/libssh/poll.c +++ b/libssh/poll.c @@ -121,9 +121,13 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) { /* compute fd_sets and find largest descriptor */ for (rc = -1, max_fd = 0, i = 0; i < nfds; i++) { - if (fds[i].fd == SSH_INVALID_SOCKET || fds[i].fd >= FD_SETSIZE) { + if (fds[i].fd == SSH_INVALID_SOCKET) { continue; } + if (fds[i].fd >= FD_SETSIZE) { + rc = -1; + break; + } if (fds[i].events & (POLLIN | POLLRDNORM)) { FD_SET (fds[i].fd, &readfds); @@ -134,7 +138,7 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) { if (fds[i].events & (POLLPRI | POLLRDBAND)) { FD_SET (fds[i].fd, &exceptfds); } - if (fds[i].fd >= max_fd && + if (fds[i].fd > max_fd && (fds[i].events & (POLLIN | POLLOUT | POLLPRI | POLLRDNORM | POLLRDBAND | POLLWRNORM | POLLWRBAND))) { |