guacamole-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmuehl...@apache.org
Subject [2/7] incubator-guacamole-server git commit: GUACAMOLE-118: Migrate to poll() instead of select() for guacd's SSL/TLS guac_socket implementation.
Date Sat, 12 Nov 2016 00:21:52 GMT
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 <mjumper@apache.org>
Authored: Fri Nov 11 13:06:05 2016 -0800
Committer: Michael Jumper <mjumper@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) {


Mime
View raw message