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

This commit is contained in:
Michael Jumper 2016-03-17 18:29:27 -07:00
parent 0a1f01ce3f
commit 1cb4325422
2 changed files with 14 additions and 13 deletions

View File

@ -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)); 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 */ /* Skip if not yet connected */
freerdp* rdp_inst = rdp_client->rdp_inst; freerdp* rdp_inst = rdp_client->rdp_inst;
if (rdp_inst == NULL) { 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; 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 button mask unchanged, just send move event */
if (mask == rdp_client->mouse_button_mask) if (mask == rdp_client->mouse_button_mask)
rdp_inst->input->MouseEvent(rdp_inst->input, PTR_FLAGS_MOVE, x, y); rdp_inst->input->MouseEvent(rdp_inst->input, PTR_FLAGS_MOVE, x, y);

View File

@ -764,8 +764,6 @@ static int guac_rdp_handle_connection(guac_client* client) {
__guac_rdp_client_load_keymap(client, settings->server_layout); __guac_rdp_client_load_keymap(client, settings->server_layout);
#ifdef ENABLE_COMMON_SSH #ifdef ENABLE_COMMON_SSH
guac_common_ssh_init(client);
/* Connect via SSH if SFTP is enabled */ /* Connect via SSH if SFTP is enabled */
if (settings->enable_sftp) { if (settings->enable_sftp) {
@ -993,6 +991,7 @@ static int guac_rdp_handle_connection(guac_client* client) {
/* Clean up RDP client */ /* Clean up RDP client */
freerdp_free(rdp_inst); freerdp_free(rdp_inst);
rdp_client->rdp_inst = NULL;
/* Clean up filesystem, if allocated */ /* Clean up filesystem, if allocated */
if (rdp_client->filesystem != NULL) if (rdp_client->filesystem != NULL)
@ -1014,8 +1013,6 @@ static int guac_rdp_handle_connection(guac_client* client) {
/* Free SFTP user */ /* Free SFTP user */
if (rdp_client->sftp_user) if (rdp_client->sftp_user)
guac_common_ssh_destroy_user(rdp_client->sftp_user); guac_common_ssh_destroy_user(rdp_client->sftp_user);
guac_common_ssh_uninit();
#endif #endif
/* Free SVC list */ /* Free SVC list */
@ -1024,9 +1021,6 @@ static int guac_rdp_handle_connection(guac_client* client) {
/* Free display */ /* Free display */
guac_common_display_free(rdp_client->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)); pthread_mutex_unlock(&(rdp_client->rdp_lock));
return 0; return 0;
@ -1036,13 +1030,20 @@ void* guac_rdp_client_thread(void* data) {
guac_client* client = (guac_client*) data; guac_client* client = (guac_client*) data;
#ifdef ENABLE_COMMON_SSH
guac_common_ssh_init(client);
#endif
/* Continue handling connections until error or client disconnect */
while (client->state == GUAC_CLIENT_RUNNING) { while (client->state == GUAC_CLIENT_RUNNING) {
if (guac_rdp_handle_connection(client)) if (guac_rdp_handle_connection(client))
return NULL; break;
} }
#ifdef ENABLE_COMMON_SSH
guac_common_ssh_uninit();
#endif
return NULL; return NULL;
} }