From 168359344e4003768b57704b6daca53095bec19f Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 11 Nov 2016 13:13:48 -0800 Subject: [PATCH] GUACAMOLE-118: Use poll() when waiting for data from Telnet. --- src/protocols/telnet/telnet.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/protocols/telnet/telnet.c b/src/protocols/telnet/telnet.c index 8ac6ed0c..6ca9aba7 100644 --- a/src/protocols/telnet/telnet.c +++ b/src/protocols/telnet/telnet.c @@ -29,10 +29,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -442,17 +442,15 @@ void guac_telnet_send_user(telnet_t* telnet, const char* username) { */ static int __guac_telnet_wait(int socket_fd) { - fd_set fds; - struct timeval timeout; - - FD_ZERO(&fds); - FD_SET(socket_fd, &fds); + /* Build array of file descriptors */ + struct pollfd fds[] = {{ + .fd = socket_fd, + .events = POLLIN, + .revents = 0, + }}; /* Wait for one second */ - timeout.tv_sec = 1; - timeout.tv_usec = 0; - - return select(socket_fd+1, &fds, NULL, NULL, &timeout); + return poll(fds, 1, 1000); }