From 2421fc2f11fd94b099acde844591bb348c86f1e3 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 11 Nov 2016 13:16:57 -0800 Subject: [PATCH] GUACAMOLE-118: Use poll() when waiting for data from SSH. --- src/protocols/ssh/ssh.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index f887cc23..db3cea96 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -44,13 +44,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include @@ -362,19 +362,18 @@ void* ssh_client_thread(void* data) { /* Wait for more data if reads turn up empty */ if (total_read == 0) { - fd_set fds; - struct timeval timeout; - FD_ZERO(&fds); - FD_SET(ssh_client->session->fd, &fds); + /* Wait on the SSH session file descriptor only */ + struct pollfd fds[] = {{ + .fd = ssh_client->session->fd, + .events = POLLIN, + .revents = 0, + }}; - /* Wait for one second */ - timeout.tv_sec = 1; - timeout.tv_usec = 0; - - if (select(ssh_client->session->fd + 1, &fds, - NULL, NULL, &timeout) < 0) + /* Wait up to one second */ + if (poll(fds, 1, 1000) < 0) break; + } }