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:51 UTC

[1/7] incubator-guacamole-server git commit: GUACAMOLE-118: Migrate to poll() instead of select() for file descriptor guac_socket implementation.

Repository: incubator-guacamole-server
Updated Branches:
  refs/heads/master 6436996eb -> 7c3430ba0


GUACAMOLE-118: Migrate to poll() instead of select() for file descriptor guac_socket implementation.


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/9d6d2aeb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/9d6d2aeb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/9d6d2aeb

Branch: refs/heads/master
Commit: 9d6d2aeba7fd772de14dfe6f2ed4b0fc5a719fb3
Parents: a46ce4c
Author: Michael Jumper <mj...@apache.org>
Authored: Fri Nov 11 13:03:43 2016 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Fri Nov 11 13:03:43 2016 -0800

----------------------------------------------------------------------
 src/libguac/socket-fd.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/9d6d2aeb/src/libguac/socket-fd.c
----------------------------------------------------------------------
diff --git a/src/libguac/socket-fd.c b/src/libguac/socket-fd.c
index 8190b86..0ed5748 100644
--- a/src/libguac/socket-fd.c
+++ b/src/libguac/socket-fd.c
@@ -22,6 +22,7 @@
 #include "error.h"
 #include "socket.h"
 
+#include <poll.h>
 #include <pthread.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -30,12 +31,6 @@
 #include <sys/time.h>
 #include <unistd.h>
 
-#ifdef __MINGW32__
-#include <winsock2.h>
-#else
-#include <sys/select.h>
-#endif
-
 /**
  * Data associated with an open socket which writes to a file descriptor.
  */
@@ -337,24 +332,22 @@ static int guac_socket_fd_select_handler(guac_socket* socket,
 
     guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data;
 
-    fd_set fds;
-    struct timeval timeout;
     int retval;
 
-    /* Initialize fd_set with single underlying file descriptor */
-    FD_ZERO(&fds);
-    FD_SET(data->fd, &fds);
+    /* Initialize with single underlying file descriptor */
+    struct pollfd fds[1] = {{
+        .fd      = data->fd,
+        .events  = POLLIN,
+        .revents = 0,
+    }};
 
     /* No timeout if usec_timeout is negative */
     if (usec_timeout < 0)
-        retval = select(data->fd + 1, &fds, NULL, NULL, NULL); 
+        retval = poll(fds, 1, -1);
 
-    /* Handle timeout if specified */
-    else {
-        timeout.tv_sec = usec_timeout/1000000;
-        timeout.tv_usec = usec_timeout%1000000;
-        retval = select(data->fd + 1, &fds, NULL, NULL, &timeout);
-    }
+    /* Handle timeout if specified, rounding up to poll()'s granularity */
+    else
+        retval = poll(fds, 1, (usec_timeout + 999) / 1000);
 
     /* Properly set guac_error */
     if (retval <  0) {


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

Posted by jm...@apache.org.
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);
 
 }
 


[4/7] incubator-guacamole-server git commit: GUACAMOLE-118: Use poll() when waiting for data from Telnet.

Posted by jm...@apache.org.
GUACAMOLE-118: Use poll() when waiting for data from Telnet.


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/16835934
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/16835934
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/16835934

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

----------------------------------------------------------------------
 src/protocols/telnet/telnet.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/16835934/src/protocols/telnet/telnet.c
----------------------------------------------------------------------
diff --git a/src/protocols/telnet/telnet.c b/src/protocols/telnet/telnet.c
index 8ac6ed0..6ca9aba 100644
--- a/src/protocols/telnet/telnet.c
+++ b/src/protocols/telnet/telnet.c
@@ -29,10 +29,10 @@
 #include <errno.h>
 #include <netdb.h>
 #include <netinet/in.h>
+#include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/time.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) {
 
-    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);
 
 }
 


[7/7] incubator-guacamole-server git commit: GUACAMOLE-118: Merge switchover from select to poll.

Posted by jm...@apache.org.
GUACAMOLE-118: Merge switchover from select to poll.


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/7c3430ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/7c3430ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/7c3430ba

Branch: refs/heads/master
Commit: 7c3430ba0ff068e1ba46646fa4388c67575ff17d
Parents: 6436996 c12e264
Author: James Muehlner <ja...@guac-dev.org>
Authored: Fri Nov 11 16:19:54 2016 -0800
Committer: James Muehlner <ja...@guac-dev.org>
Committed: Fri Nov 11 16:19:54 2016 -0800

----------------------------------------------------------------------
 src/guacd/socket-ssl.c        | 24 +++++-----
 src/libguac/socket-fd.c       | 29 +++++--------
 src/protocols/rdp/client.h    | 16 ++++---
 src/protocols/rdp/rdp.c       | 89 +++++++++++++++++++-------------------
 src/protocols/ssh/ssh.c       | 21 +++++----
 src/protocols/telnet/telnet.c | 18 ++++----
 src/terminal/terminal.c       | 20 ++++-----
 7 files changed, 103 insertions(+), 114 deletions(-)
----------------------------------------------------------------------



[2/7] incubator-guacamole-server git commit: GUACAMOLE-118: Migrate to poll() instead of select() for guacd's SSL/TLS guac_socket implementation.

Posted by jm...@apache.org.
GUACAMOLE-118: Migrate to poll() instead of select() for guacd's SSL/TLS guac_socket implementation.


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/12d575b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/12d575b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/12d575b8

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

----------------------------------------------------------------------
 src/guacd/socket-ssl.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/12d575b8/src/guacd/socket-ssl.c
----------------------------------------------------------------------
diff --git a/src/guacd/socket-ssl.c b/src/guacd/socket-ssl.c
index 32e82a2..4f19442 100644
--- a/src/guacd/socket-ssl.c
+++ b/src/guacd/socket-ssl.c
@@ -21,8 +21,8 @@
 
 #include "socket-ssl.h"
 
+#include <poll.h>
 #include <stdlib.h>
-#include <sys/select.h>
 
 #include <guacamole/error.h>
 #include <guacamole/socket.h>
@@ -70,24 +70,22 @@ static int __guac_socket_ssl_select_handler(guac_socket* socket, int usec_timeou
 
     guac_socket_ssl_data* data = (guac_socket_ssl_data*) socket->data;
 
-    fd_set fds;
-    struct timeval timeout;
     int retval;
 
-    /* Initialize fd_set with single underlying file descriptor */
-    FD_ZERO(&fds);
-    FD_SET(data->fd, &fds);
+    /* Initialize with single underlying file descriptor */
+    struct pollfd fds[1] = {{
+        .fd      = data->fd,
+        .events  = POLLIN,
+        .revents = 0,
+    }};
 
     /* No timeout if usec_timeout is negative */
     if (usec_timeout < 0)
-        retval = select(data->fd + 1, &fds, NULL, NULL, NULL); 
+        retval = poll(fds, 1, -1);
 
-    /* Handle timeout if specified */
-    else {
-        timeout.tv_sec = usec_timeout/1000000;
-        timeout.tv_usec = usec_timeout%1000000;
-        retval = select(data->fd + 1, &fds, NULL, NULL, &timeout);
-    }
+    /* Handle timeout if specified, rounding up to poll()'s granularity */
+    else
+        retval = poll(fds, 1, (usec_timeout + 999) / 1000);
 
     /* Properly set guac_error */
     if (retval <  0) {


[6/7] incubator-guacamole-server git commit: GUACAMOLE-118: Use poll() when waiting for data from RDP. Reformat for sake of readability/verification.

Posted by jm...@apache.org.
GUACAMOLE-118: Use poll() when waiting for data from RDP. Reformat for sake of readability/verification.


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/c12e2640
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/c12e2640
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/c12e2640

Branch: refs/heads/master
Commit: c12e26404a07333b6edc20c0ec1f68d8ae49ac10
Parents: 2421fc2
Author: Michael Jumper <mj...@apache.org>
Authored: Fri Nov 11 13:45:01 2016 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Fri Nov 11 13:45:01 2016 -0800

----------------------------------------------------------------------
 src/protocols/rdp/client.h | 16 +++++---
 src/protocols/rdp/rdp.c    | 89 ++++++++++++++++++++---------------------
 2 files changed, 55 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/c12e2640/src/protocols/rdp/client.h
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/client.h b/src/protocols/rdp/client.h
index 96f25bc..4f6c266 100644
--- a/src/protocols/rdp/client.h
+++ b/src/protocols/rdp/client.h
@@ -38,12 +38,12 @@
 
 /**
  * The amount of time to wait for a new message from the RDP server when
- * beginning a new frame. This value must be kept reasonably small such that
- * a slow RDP server will not prevent external events from being handled (such
- * as the stop signal from guac_client_stop()), but large enough that the
- * message handling loop does not eat up CPU spinning.
+ * beginning a new frame, in milliseconds. This value must be kept reasonably
+ * small such that a slow RDP server will not prevent external events from
+ * being handled (such as the stop signal from guac_client_stop()), but large
+ * enough that the message handling loop does not eat up CPU spinning.
  */
-#define GUAC_RDP_FRAME_START_TIMEOUT 250000
+#define GUAC_RDP_FRAME_START_TIMEOUT 250
 
 /**
  * The native resolution of most RDP connections. As Windows and other systems
@@ -90,6 +90,12 @@
 #define GUAC_RDP_AUDIO_BPS 16
 
 /**
+ * The maximum number of file descriptors which can be associated with an RDP
+ * connection.
+ */
+#define GUAC_RDP_MAX_FILE_DESCRIPTORS 32
+
+/**
  * Handler which frees all data associated with the guac_client.
  */
 guac_client_free_handler guac_rdp_client_free_handler;

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/c12e2640/src/protocols/rdp/rdp.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c
index e82e526..e759888 100644
--- a/src/protocols/rdp/rdp.c
+++ b/src/protocols/rdp/rdp.c
@@ -97,10 +97,10 @@
 #endif
 
 #include <errno.h>
+#include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/select.h>
 #include <sys/time.h>
 #include <time.h>
 
@@ -545,20 +545,20 @@ static void rdp_freerdp_context_free(freerdp* instance, rdpContext* context) {
 }
 
 /**
- * Waits for messages from the RDP server for the given number of microseconds.
+ * Waits for messages from the RDP server for the given number of milliseconds.
  *
  * @param client
  *     The client associated with the current RDP session.
  *
- * @param timeout_usecs
- *     The maximum amount of time to wait, in microseconds.
+ * @param timeout_msecs
+ *     The maximum amount of time to wait, in milliseconds.
  *
  * @return
  *     A positive value if messages are ready, zero if the specified timeout
  *     period elapsed, or a negative value if an error occurs.
  */
 static int rdp_guac_client_wait_for_messages(guac_client* client,
-        int timeout_usecs) {
+        int timeout_msecs) {
 
     guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
     freerdp* rdp_inst = rdp_client->rdp_inst;
@@ -566,58 +566,56 @@ static int rdp_guac_client_wait_for_messages(guac_client* client,
 
     int result;
     int index;
-    int max_fd, fd;
-    void* read_fds[32];
-    void* write_fds[32];
+
+    /* List of all file descriptors which we may read data from */
+    void* read_fds[GUAC_RDP_MAX_FILE_DESCRIPTORS];
     int read_count = 0;
+
+    /* List of all file descriptors which data may be written to. These will
+     * ultimately be ignored, but FreeRDP requires that both read and write
+     * file descriptors be retrieved simultaneously. */
+    void* write_fds[GUAC_RDP_MAX_FILE_DESCRIPTORS];
     int write_count = 0;
-    fd_set rfds, wfds;
 
-    struct timeval timeout = {
-        .tv_sec  = 0,
-        .tv_usec = timeout_usecs
-    };
+    struct pollfd fds[GUAC_RDP_MAX_FILE_DESCRIPTORS];
 
-    /* Get RDP fds */
-    if (!freerdp_get_fds(rdp_inst, read_fds, &read_count, write_fds, &write_count)) {
-        guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Unable to read RDP file descriptors.");
+    /* Get RDP file descriptors */
+    if (!freerdp_get_fds(rdp_inst, read_fds, &read_count,
+                write_fds, &write_count)) {
+        guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
+                "Unable to read RDP file descriptors.");
         return -1;
     }
 
-    /* Get channel fds */
-    if (!freerdp_channels_get_fds(channels, rdp_inst, read_fds, &read_count, write_fds,
-                &write_count)) {
-        guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Unable to read RDP channel file descriptors.");
+    /* Get RDP channel file descriptors */
+    if (!freerdp_channels_get_fds(channels, rdp_inst, read_fds, &read_count,
+                write_fds, &write_count)) {
+        guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
+                "Unable to read RDP channel file descriptors.");
         return -1;
     }
 
-    /* Construct read fd_set */
-    max_fd = 0;
-    FD_ZERO(&rfds);
-    for (index = 0; index < read_count; index++) {
-        fd = (int)(long) (read_fds[index]);
-        if (fd > max_fd)
-            max_fd = fd;
-        FD_SET(fd, &rfds);
+    /* If no file descriptors, error */
+    if (read_count == 0) {
+        guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
+                "No file descriptors associated with RDP connection.");
+        return -1;
     }
 
-    /* Construct write fd_set */
-    FD_ZERO(&wfds);
-    for (index = 0; index < write_count; index++) {
-        fd = (int)(long) (write_fds[index]);
-        if (fd > max_fd)
-            max_fd = fd;
-        FD_SET(fd, &wfds);
-    }
+    /* Populate poll() array of read file descriptors */
+    for (index = 0; index < read_count; index++) {
+
+        struct pollfd* current = &fds[index];
+
+        /* Init poll() array element with RDP file descriptor */
+        current->fd      = (int)(long) (read_fds[index]);
+        current->events  = POLLIN;
+        current->revents = 0;
 
-    /* If no file descriptors, error */
-    if (max_fd == 0) {
-        guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "No file descriptors associated with RDP connection.");
-        return -1;
     }
 
-    /* Wait for all RDP file descriptors */
-    result = select(max_fd + 1, &rfds, &wfds, NULL, &timeout);
+    /* Wait until data can be read from RDP file descriptors */
+    result = poll(fds, read_count, timeout_msecs);
     if (result < 0) {
 
         /* If error ignorable, pretend timout occurred */
@@ -628,7 +626,8 @@ static int rdp_guac_client_wait_for_messages(guac_client* client,
             return 0;
 
         /* Otherwise, return as error */
-        guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Error waiting for file descriptor.");
+        guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
+                "Error waiting for file descriptor.");
         return -1;
 
     }
@@ -823,12 +822,12 @@ static int guac_rdp_handle_connection(guac_client* client) {
                 /* Increase the duration of this frame if client is lagging */
                 if (required_wait > GUAC_RDP_FRAME_TIMEOUT)
                     wait_result = rdp_guac_client_wait_for_messages(client,
-                            required_wait*1000);
+                            required_wait);
 
                 /* Wait again if frame remaining */
                 else if (frame_remaining > 0)
                     wait_result = rdp_guac_client_wait_for_messages(client,
-                            GUAC_RDP_FRAME_TIMEOUT*1000);
+                            GUAC_RDP_FRAME_TIMEOUT);
                 else
                     break;
 


[5/7] incubator-guacamole-server git commit: GUACAMOLE-118: Use poll() when waiting for data from SSH.

Posted by jm...@apache.org.
GUACAMOLE-118: Use poll() when waiting for data from SSH.


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/2421fc2f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/2421fc2f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/2421fc2f

Branch: refs/heads/master
Commit: 2421fc2f11fd94b099acde844591bb348c86f1e3
Parents: 1683593
Author: Michael Jumper <mj...@apache.org>
Authored: Fri Nov 11 13:16:57 2016 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Fri Nov 11 13:16:57 2016 -0800

----------------------------------------------------------------------
 src/protocols/ssh/ssh.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/2421fc2f/src/protocols/ssh/ssh.c
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c
index f887cc2..db3cea9 100644
--- a/src/protocols/ssh/ssh.c
+++ b/src/protocols/ssh/ssh.c
@@ -44,13 +44,13 @@
 #include <errno.h>
 #include <netdb.h>
 #include <netinet/in.h>
+#include <poll.h>
 #include <pthread.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/time.h>
 
@@ -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;
+
         }
 
     }