GUAC-1164: Init/uninit common SSH client only once. Do not touch display if RDP 
server is not connected.


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

Branch: refs/heads/master
Commit: 1cb4325422270f6305ad94bd3bce6dfa89cb2c37
Parents: 0a1f01c
Author: Michael Jumper <[email protected]>
Authored: Thu Mar 17 18:29:27 2016 -0700
Committer: Michael Jumper <[email protected]>
Committed: Thu Mar 17 18:29:27 2016 -0700

----------------------------------------------------------------------
 src/protocols/rdp/input.c |  6 +++---
 src/protocols/rdp/rdp.c   | 21 +++++++++++----------
 2 files changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/1cb43254/src/protocols/rdp/input.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/input.c b/src/protocols/rdp/input.c
index 8a8cbaf..6aff96b 100644
--- a/src/protocols/rdp/input.c
+++ b/src/protocols/rdp/input.c
@@ -165,9 +165,6 @@ int guac_rdp_user_mouse_handler(guac_user* user, int x, int 
y, int mask) {
 
     pthread_mutex_lock(&(rdp_client->rdp_lock));
 
-    /* Store current mouse location */
-    guac_common_cursor_move(rdp_client->display->cursor, user, x, y);
-
     /* Skip if not yet connected */
     freerdp* rdp_inst = rdp_client->rdp_inst;
     if (rdp_inst == NULL) {
@@ -175,6 +172,9 @@ int guac_rdp_user_mouse_handler(guac_user* user, int x, int 
y, int mask) {
         return 0;
     }
 
+    /* Store current mouse location */
+    guac_common_cursor_move(rdp_client->display->cursor, user, x, y);
+
     /* If button mask unchanged, just send move event */
     if (mask == rdp_client->mouse_button_mask)
         rdp_inst->input->MouseEvent(rdp_inst->input, PTR_FLAGS_MOVE, x, y);

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/1cb43254/src/protocols/rdp/rdp.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c
index 80158db..4654fc8 100644
--- a/src/protocols/rdp/rdp.c
+++ b/src/protocols/rdp/rdp.c
@@ -764,8 +764,6 @@ static int guac_rdp_handle_connection(guac_client* client) {
     __guac_rdp_client_load_keymap(client, settings->server_layout);
 
 #ifdef ENABLE_COMMON_SSH
-    guac_common_ssh_init(client);
-
     /* Connect via SSH if SFTP is enabled */
     if (settings->enable_sftp) {
 
@@ -993,6 +991,7 @@ static int guac_rdp_handle_connection(guac_client* client) {
 
     /* Clean up RDP client */
     freerdp_free(rdp_inst);
+    rdp_client->rdp_inst = NULL;
 
     /* Clean up filesystem, if allocated */
     if (rdp_client->filesystem != NULL)
@@ -1014,8 +1013,6 @@ static int guac_rdp_handle_connection(guac_client* 
client) {
     /* Free SFTP user */
     if (rdp_client->sftp_user)
         guac_common_ssh_destroy_user(rdp_client->sftp_user);
-
-    guac_common_ssh_uninit();
 #endif
 
     /* Free SVC list */
@@ -1024,9 +1021,6 @@ static int guac_rdp_handle_connection(guac_client* 
client) {
     /* Free display */
     guac_common_display_free(rdp_client->display);
 
-    /* Mark FreeRDP instance as freed */
-    rdp_client->rdp_inst = NULL;
-
     pthread_mutex_unlock(&(rdp_client->rdp_lock));
     return 0;
 
@@ -1036,13 +1030,20 @@ void* guac_rdp_client_thread(void* data) {
 
     guac_client* client = (guac_client*) data;
 
-    while (client->state == GUAC_CLIENT_RUNNING) {
+#ifdef ENABLE_COMMON_SSH
+    guac_common_ssh_init(client);
+#endif
 
+    /* Continue handling connections until error or client disconnect */
+    while (client->state == GUAC_CLIENT_RUNNING) {
         if (guac_rdp_handle_connection(client))
-            return NULL;
-
+            break;
     }
 
+#ifdef ENABLE_COMMON_SSH
+    guac_common_ssh_uninit();
+#endif
+
     return NULL;
 
 }

Reply via email to