aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Wiley <wiley@outlook.com>2021-05-07 12:38:00 -0700
committerJakub Jelen <jjelen@redhat.com>2021-10-11 14:01:09 +0200
commit1a831cfe2c5c6394a92f3fe37cbfd88cc149187d (patch)
tree86f08f80b08600cddbab9fab3f46b711bc18abac /src
parent95539ba0ebe0f71f77c621befb26dd836f0ffd0c (diff)
downloadlibssh-master.tar.gz
libssh-master.tar.xz
libssh-master.zip
emulated poll: polling for nothing should at least get socket errorsHEADmaster
Signed-off-by: Andrew Wiley <wiley@outlook.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/poll.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/poll.c b/src/poll.c
index 46206949..82c9b18b 100644
--- a/src/poll.c
+++ b/src/poll.c
@@ -246,19 +246,17 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout)
}
#endif
- if (fds[i].events & (POLLIN | POLLRDNORM)) {
- FD_SET (fds[i].fd, &readfds);
- }
+ // we use the readfds to get POLLHUP and POLLERR, which are provided even when not requested
+ FD_SET (fds[i].fd, &readfds);
+
if (fds[i].events & (POLLOUT | POLLWRNORM | POLLWRBAND)) {
FD_SET (fds[i].fd, &writefds);
}
if (fds[i].events & (POLLPRI | POLLRDBAND)) {
FD_SET (fds[i].fd, &exceptfds);
}
- if (fds[i].fd > max_fd &&
- (fds[i].events & (POLLIN | POLLOUT | POLLPRI |
- POLLRDNORM | POLLRDBAND |
- POLLWRNORM | POLLWRBAND))) {
+
+ if (fds[i].fd > max_fd) {
max_fd = fds[i].fd;
rc = 0;
}