You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by jm...@apache.org on 2016/11/12 00:21:53 UTC

[3/7] incubator-guacamole-server git commit: GUACAMOLE-118: Use poll() when waiting for data to be written to the terminal emulator.

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


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/commit/a1fc5bc7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/a1fc5bc7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/a1fc5bc7

Branch: refs/heads/master
Commit: a1fc5bc733f50c54e261352312a4b90d21731b07
Parents: 12d575b
Author: Michael Jumper <mj...@apache.org>
Authored: Fri Nov 11 13:12:12 2016 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Fri Nov 11 13:12:12 2016 -0800

----------------------------------------------------------------------
 src/terminal/terminal.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/a1fc5bc7/src/terminal/terminal.c
----------------------------------------------------------------------
diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c
index 174e0d4..598a385 100644
--- a/src/terminal/terminal.c
+++ b/src/terminal/terminal.c
@@ -32,12 +32,12 @@
 #include "typescript.h"
 
 #include <errno.h>
+#include <poll.h>
 #include <pthread.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/select.h>
 #include <sys/time.h>
 #include <unistd.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) {
 
-    /* Build fd_set */
-    fd_set fds;
-    FD_ZERO(&fds);
-    FD_SET(fd, &fds);
-
-    /* Split millisecond timeout into seconds and microseconds */
-    struct timeval timeout = {
-        .tv_sec  =  msec_timeout / 1000,
-        .tv_usec = (msec_timeout % 1000) * 1000
-    };
+    /* Build array of file descriptors */
+    struct pollfd fds[] = {{
+        .fd      = fd,
+        .events  = POLLIN,
+        .revents = 0,
+    }};
 
     /* Wait for data */
-    return select(fd+1, &fds, NULL, NULL, &timeout);
+    return poll(fds, 1, msec_timeout);
 
 }