GUACAMOLE-118: Use poll() when waiting for data to be written to the terminal emulator.

This commit is contained in:
Michael Jumper 2016-11-11 13:12:12 -08:00
parent 12d575b8e6
commit a1fc5bc733

View File

@ -32,12 +32,12 @@
#include "typescript.h" #include "typescript.h"
#include <errno.h> #include <errno.h>
#include <poll.h>
#include <pthread.h> #include <pthread.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/select.h>
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include <wchar.h> #include <wchar.h>
@ -463,19 +463,15 @@ void guac_terminal_free(guac_terminal* term) {
*/ */
static int guac_terminal_wait_for_data(int fd, int msec_timeout) { static int guac_terminal_wait_for_data(int fd, int msec_timeout) {
/* Build fd_set */ /* Build array of file descriptors */
fd_set fds; struct pollfd fds[] = {{
FD_ZERO(&fds); .fd = fd,
FD_SET(fd, &fds); .events = POLLIN,
.revents = 0,
/* Split millisecond timeout into seconds and microseconds */ }};
struct timeval timeout = {
.tv_sec = msec_timeout / 1000,
.tv_usec = (msec_timeout % 1000) * 1000
};
/* Wait for data */ /* Wait for data */
return select(fd+1, &fds, NULL, NULL, &timeout); return poll(fds, 1, msec_timeout);
} }