GUACAMOLE-203: Deal correctly with negative keepalive values.

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

Branch: refs/heads/master
Commit: 05dfb1a6ae931564458ba6f66360bd12a9ae783f
Parents: ed77114
Author: Nick Couchman <vn...@apache.org>
Authored: Sun Jun 25 04:49:05 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Sun Jun 25 05:10:22 2017 -0400

----------------------------------------------------------------------
 src/common-ssh/ssh.c             | 14 +++++++++-----
 src/protocols/rdp/rdp_settings.h |  2 +-
 src/protocols/ssh/settings.h     |  2 +-
 src/protocols/vnc/settings.h     |  2 +-
 4 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/05dfb1a6/src/common-ssh/ssh.c
----------------------------------------------------------------------
diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c
index 50ab7e0..d7da64a 100644
--- a/src/common-ssh/ssh.c
+++ b/src/common-ssh/ssh.c
@@ -532,16 +532,20 @@ guac_common_ssh_session* 
guac_common_ssh_create_session(guac_client* client,
         return NULL;
     }
 
-    /* Configure session keepalive */
-    if (keepalive > 0)
-        libssh2_keepalive_config(common_session->session, 1, keepalive);
-
     /* Warn if keepalive below minimum value */
-    if (keepalive == 1) {
+    if (keepalive < 0) {
+        keepalive = 0;
+        guac_client_log(client, GUAC_LOG_WARNING, "negative keepalive 
intervals "
+            "are converted to 0, disabling keepalive.");
+    }
+    else if(keepalive == 1) {
         guac_client_log(client, GUAC_LOG_WARNING, "keepalive interval will "
             "be rounded up to minimum value of 2.");
     }
 
+    /* Configure session keepalive */
+    libssh2_keepalive_config(common_session->session, 1, keepalive);
+
     /* Return created session */
     return common_session;
 

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/05dfb1a6/src/protocols/rdp/rdp_settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h
index e2013b7..8edb79e 100644
--- a/src/protocols/rdp/rdp_settings.h
+++ b/src/protocols/rdp/rdp_settings.h
@@ -366,7 +366,7 @@ typedef struct guac_rdp_settings {
      * of 1 is automatically increased to 2 by libssh2 to avoid busy loop 
corner
      * cases.
      */
-    unsigned sftp_server_alive_interval;
+    int sftp_server_alive_interval;
 #endif
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/05dfb1a6/src/protocols/ssh/settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h
index ea9f5ac..f49d054 100644
--- a/src/protocols/ssh/settings.h
+++ b/src/protocols/ssh/settings.h
@@ -189,7 +189,7 @@ typedef struct guac_ssh_settings {
     /**
      * The number of seconds between sending server alive messages.
      */
-    unsigned server_alive_interval;
+    int server_alive_interval;
 
 } guac_ssh_settings;
 

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/05dfb1a6/src/protocols/vnc/settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h
index a9ce82c..3c7b258 100644
--- a/src/protocols/vnc/settings.h
+++ b/src/protocols/vnc/settings.h
@@ -180,7 +180,7 @@ typedef struct guac_vnc_settings {
      * of 1 is automatically increased to 2 by libssh2 to avoid busy loop 
corner
      * cases.
      */
-    unsigned sftp_server_alive_interval;
+    int sftp_server_alive_interval;
 #endif
 
     /**

Reply via email to