mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-02 01:17:52 +03:00
poll: Another attempt to get bsd_poll() working correctly.
This commit is contained in:
@@ -146,9 +146,13 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
|
|||||||
|
|
||||||
/* compute fd_sets and find largest descriptor */
|
/* compute fd_sets and find largest descriptor */
|
||||||
for (rc = -1, 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 || fds[i].fd >= FD_SETSIZE) {
|
if (fds[i].fd == SSH_INVALID_SOCKET) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (fds[i].fd >= FD_SETSIZE) {
|
||||||
|
rc = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (fds[i].events & (POLLIN | POLLRDNORM)) {
|
if (fds[i].events & (POLLIN | POLLRDNORM)) {
|
||||||
FD_SET (fds[i].fd, &readfds);
|
FD_SET (fds[i].fd, &readfds);
|
||||||
@@ -159,7 +163,7 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
|
|||||||
if (fds[i].events & (POLLPRI | POLLRDBAND)) {
|
if (fds[i].events & (POLLPRI | POLLRDBAND)) {
|
||||||
FD_SET (fds[i].fd, &exceptfds);
|
FD_SET (fds[i].fd, &exceptfds);
|
||||||
}
|
}
|
||||||
if (fds[i].fd >= max_fd &&
|
if (fds[i].fd > max_fd &&
|
||||||
(fds[i].events & (POLLIN | POLLOUT | POLLPRI |
|
(fds[i].events & (POLLIN | POLLOUT | POLLPRI |
|
||||||
POLLRDNORM | POLLRDBAND |
|
POLLRDNORM | POLLRDBAND |
|
||||||
POLLWRNORM | POLLWRBAND))) {
|
POLLWRNORM | POLLWRBAND))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user