Fixed whitespace, moved timeout declaration.
[libguac-client-rdp.git] / src / guac_handlers.c
index 94f274c..c77940a 100644 (file)
@@ -75,17 +75,21 @@ int rdp_guac_client_handle_messages(guac_client* client) {
     void* write_fds[32];
     int read_count = 0;
     int write_count = 0;
-
     fd_set rfds, wfds;
 
+    struct timeval timeout = {
+        .tv_sec = 0;
+        .tv_usec = 250000;
+    };
+
     /* get rdp fds */
-    if (freerdp_get_fds(rdp_inst, read_fds, &read_count, write_fds, &write_count) != 0) {
+    if (!freerdp_get_fds(rdp_inst, read_fds, &read_count, write_fds, &write_count)) {
         guac_client_log_error(client, "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) != 0) {
+    if (!freerdp_channels_get_fds(channels, rdp_inst, read_fds, &read_count, write_fds, &write_count)) {
         guac_client_log_error(client, "Unable to read RDP channel file descriptors.");
         return 1;
     }
@@ -116,7 +120,7 @@ int rdp_guac_client_handle_messages(guac_client* client) {
     }
 
     /* Otherwise, wait for file descriptors given */
-    if (select(max_fd + 1, &rfds, &wfds, NULL, NULL) == -1) {
+    if (select(max_fd + 1, &rfds, &wfds, NULL, &timeout) == -1) {
         /* these are not really errors */
         if (!((errno == EAGAIN) ||
             (errno == EWOULDBLOCK) ||
@@ -128,14 +132,14 @@ int rdp_guac_client_handle_messages(guac_client* client) {
         }
     }
 
-    /* check the libfreerdp fds */
-    if (freerdp_check_fds(rdp_inst) != 0) {
+    /* Check the libfreerdp fds */
+    if (!freerdp_check_fds(rdp_inst)) {
         guac_client_log_error(client, "Error handling RDP file descriptors.");
         return 1;
     }
 
-    /* check channel fds */
-    if (freerdp_channels_check_fds(channels, rdp_inst) != 0) {
+    /* Check channel fds */
+    if (!freerdp_channels_check_fds(channels, rdp_inst)) {
         guac_client_log_error(client, "Error handling RDP channel file descriptors.");
         return 1;
     }