You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2017/06/25 19:02:18 UTC
[04/21] incubator-guacamole-server git commit: GUACAMOLE-203: Tighten
up code, implement constant for socket poll timer.
GUACAMOLE-203: Tighten up code, implement constant for socket poll timer.
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/f693b02e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/f693b02e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/f693b02e
Branch: refs/heads/master
Commit: f693b02e126e7d3f348744fdf0975278c897add2
Parents: 75019f5
Author: Nick Couchman <vn...@apache.org>
Authored: Wed May 31 19:33:47 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Wed May 31 21:02:59 2017 -0400
----------------------------------------------------------------------
src/protocols/ssh/settings.h | 5 +++++
src/protocols/ssh/ssh.c | 26 ++++++++++----------------
2 files changed, 15 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/f693b02e/src/protocols/ssh/settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h
index 3440e5b..e831d9e 100644
--- a/src/protocols/ssh/settings.h
+++ b/src/protocols/ssh/settings.h
@@ -54,6 +54,11 @@
#define GUAC_SSH_DEFAULT_RECORDING_NAME "recording"
/**
+ * The default polling timer for SSH activity in milliseconds.
+ */
+#define GUAC_SSH_DEFAULT_POLL_TIMER 1000
+
+/**
* Settings for the SSH connection. The values for this structure are parsed
* from the arguments given during the Guacamole protocol handshake using the
* guac_ssh_parse_args() function.
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/f693b02e/src/protocols/ssh/ssh.c
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c
index 36055c8..a1b3d93 100644
--- a/src/protocols/ssh/ssh.c
+++ b/src/protocols/ssh/ssh.c
@@ -225,9 +225,8 @@ void* ssh_client_thread(void* data) {
}
/* Set keepalive configuration for session */
- if (settings->server_alive_interval > 0) {
+ if (settings->server_alive_interval > 1)
libssh2_keepalive_config(ssh_client->session->session, 1, settings->server_alive_interval);
- }
pthread_mutex_init(&ssh_client->term_channel_lock, NULL);
@@ -323,17 +322,13 @@ void* ssh_client_thread(void* data) {
/* While data available, write to terminal */
int bytes_read = 0;
- int timeout = 0;
for (;;) {
/* Track total amount of data read */
int total_read = 0;
- /* Set up return value for keepalives */
- int alive = 0;
-
- /* Timer for keepalives */
- int sleep = 0;
+ /* Timer for polling socket activity */
+ int timer;
pthread_mutex_lock(&(ssh_client->term_channel_lock));
@@ -344,16 +339,15 @@ void* ssh_client_thread(void* data) {
}
/* Send keepalive at configured interval */
- if (settings->server_alive_interval > 0) {
- alive = libssh2_keepalive_send(ssh_client->session->session, &timeout);
- /* Sending the keepalive failed, so we break out */
- if (alive > 0)
+ if (settings->server_alive_interval > 1) {
+ int timeout = 0;
+ if(libssh2_keepalive_send(ssh_client->session->session, &timeout) > 0)
break;
- sleep = timeout * 1000;
+ timer = timeout * 1000;
}
/* If keepalive is not configured, sleep for the default of 1 second */
else
- sleep = 1000;
+ timer = GUAC_SSH_DEFAULT_POLL_TIMER;
/* Read terminal data */
bytes_read = libssh2_channel_read(ssh_client->term_channel,
@@ -394,8 +388,8 @@ void* ssh_client_thread(void* data) {
.revents = 0,
}};
- /* Wait up to computed sleep time */
- if (poll(fds, 1, sleep) < 0)
+ /* Wait up to computed timer */
+ if (poll(fds, 1, timer) < 0)
break;
}