GUACAMOLE-118: Use poll() when waiting for data from Telnet.

This commit is contained in:
Michael Jumper 2016-11-11 13:13:48 -08:00
parent a1fc5bc733
commit 168359344e

View File

@ -29,10 +29,10 @@
#include <errno.h> #include <errno.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <poll.h>
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/select.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
@ -442,17 +442,15 @@ void guac_telnet_send_user(telnet_t* telnet, const char* username) {
*/ */
static int __guac_telnet_wait(int socket_fd) { static int __guac_telnet_wait(int socket_fd) {
fd_set fds; /* Build array of file descriptors */
struct timeval timeout; struct pollfd fds[] = {{
.fd = socket_fd,
FD_ZERO(&fds); .events = POLLIN,
FD_SET(socket_fd, &fds); .revents = 0,
}};
/* Wait for one second */ /* Wait for one second */
timeout.tv_sec = 1; return poll(fds, 1, 1000);
timeout.tv_usec = 0;
return select(socket_fd+1, &fds, NULL, NULL, &timeout);
} }