diff --git a/src/protocols/rdp/client.c b/src/protocols/rdp/client.c index 0c0b4bb8..4e724aae 100644 --- a/src/protocols/rdp/client.c +++ b/src/protocols/rdp/client.c @@ -66,9 +66,6 @@ int guac_client_init(guac_client* client, int argc, char** argv) { pthread_mutexattr_settype(&(rdp_client->attributes), PTHREAD_MUTEX_RECURSIVE); - /* Init RDP lock */ - pthread_mutex_init(&(rdp_client->rdp_lock), &(rdp_client->attributes)); - /* Set handlers */ client->join_handler = guac_rdp_user_join_handler; client->free_handler = guac_rdp_client_free_handler; diff --git a/src/protocols/rdp/input.c b/src/protocols/rdp/input.c index 2c3ef14b..9e455160 100644 --- a/src/protocols/rdp/input.c +++ b/src/protocols/rdp/input.c @@ -38,14 +38,10 @@ int guac_rdp_user_mouse_handler(guac_user* user, int x, int y, int mask) { guac_client* client = user->client; guac_rdp_client* rdp_client = (guac_rdp_client*) client->data; - pthread_mutex_lock(&(rdp_client->rdp_lock)); - /* Skip if not yet connected */ freerdp* rdp_inst = rdp_client->rdp_inst; - if (rdp_inst == NULL) { - pthread_mutex_unlock(&(rdp_client->rdp_lock)); + if (rdp_inst == NULL) return 0; - } /* Store current mouse location/state */ guac_common_cursor_update(rdp_client->display->cursor, user, x, y, mask); @@ -118,8 +114,6 @@ int guac_rdp_user_mouse_handler(guac_user* user, int x, int y, int mask) { rdp_client->mouse_button_mask = mask; } - pthread_mutex_unlock(&(rdp_client->rdp_lock)); - return 0; } @@ -155,9 +149,7 @@ int guac_rdp_user_size_handler(guac_user* user, int width, int height) { height = height * settings->resolution / user->info.optimal_resolution; /* Send display update */ - pthread_mutex_lock(&(rdp_client->rdp_lock)); guac_rdp_disp_set_size(rdp_client->disp, settings, rdp_inst, width, height); - pthread_mutex_unlock(&(rdp_client->rdp_lock)); return 0; diff --git a/src/protocols/rdp/keyboard.c b/src/protocols/rdp/keyboard.c index 88cf2daf..b0a0188b 100644 --- a/src/protocols/rdp/keyboard.c +++ b/src/protocols/rdp/keyboard.c @@ -102,21 +102,15 @@ static void guac_rdp_send_key_event(guac_rdp_client* rdp_client, else pressed_flags = KBD_FLAGS_RELEASE; - pthread_mutex_lock(&(rdp_client->rdp_lock)); - /* Skip if not yet connected */ freerdp* rdp_inst = rdp_client->rdp_inst; - if (rdp_inst == NULL) { - pthread_mutex_unlock(&(rdp_client->rdp_lock)); + if (rdp_inst == NULL) return; - } /* Send actual key */ rdp_inst->input->KeyboardEvent(rdp_inst->input, flags | pressed_flags, scancode); - pthread_mutex_unlock(&(rdp_client->rdp_lock)); - } /** @@ -136,22 +130,16 @@ static void guac_rdp_send_key_event(guac_rdp_client* rdp_client, static void guac_rdp_send_unicode_event(guac_rdp_client* rdp_client, int codepoint) { - pthread_mutex_lock(&(rdp_client->rdp_lock)); - /* Skip if not yet connected */ freerdp* rdp_inst = rdp_client->rdp_inst; - if (rdp_inst == NULL) { - pthread_mutex_unlock(&(rdp_client->rdp_lock)); + if (rdp_inst == NULL) return; - } /* Send Unicode event */ rdp_inst->input->UnicodeKeyboardEvent( rdp_inst->input, 0, codepoint); - pthread_mutex_unlock(&(rdp_client->rdp_lock)); - } /** @@ -171,20 +159,14 @@ static void guac_rdp_send_unicode_event(guac_rdp_client* rdp_client, static void guac_rdp_send_synchronize_event(guac_rdp_client* rdp_client, int flags) { - pthread_mutex_lock(&(rdp_client->rdp_lock)); - /* Skip if not yet connected */ freerdp* rdp_inst = rdp_client->rdp_inst; - if (rdp_inst == NULL) { - pthread_mutex_unlock(&(rdp_client->rdp_lock)); + if (rdp_inst == NULL) return; - } /* Synchronize lock key states */ rdp_inst->input->SynchronizeEvent(rdp_inst->input, flags); - pthread_mutex_unlock(&(rdp_client->rdp_lock)); - } /** diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index b42035ca..6d5d2254 100644 --- a/src/protocols/rdp/rdp.c +++ b/src/protocols/rdp/rdp.c @@ -405,9 +405,7 @@ static int guac_rdp_handle_connection(guac_client* client) { && !guac_rdp_disp_reconnect_needed(rdp_client->disp)) { /* Update remote display size */ - pthread_mutex_lock(&(rdp_client->rdp_lock)); guac_rdp_disp_update_size(rdp_client->disp, settings, rdp_inst); - pthread_mutex_unlock(&(rdp_client->rdp_lock)); /* Wait for data and construct a reasonable frame */ int wait_result = rdp_guac_client_wait_for_messages(client, @@ -423,20 +421,15 @@ static int guac_rdp_handle_connection(guac_client* client) { guac_timestamp frame_end; int frame_remaining; - pthread_mutex_lock(&(rdp_client->rdp_lock)); - /* Check the libfreerdp fds */ if (!freerdp_check_event_handles(rdp_inst->context)) { /* Flag connection failure */ wait_result = -1; - pthread_mutex_unlock(&(rdp_client->rdp_lock)); break; } - pthread_mutex_unlock(&(rdp_client->rdp_lock)); - /* Calculate time remaining in frame */ frame_end = guac_timestamp_current(); frame_remaining = frame_start + GUAC_RDP_FRAME_DURATION @@ -469,9 +462,7 @@ static int guac_rdp_handle_connection(guac_client* client) { } /* Test whether the RDP server is closing the connection */ - pthread_mutex_lock(&(rdp_client->rdp_lock)); int connection_closing = freerdp_shall_disconnect(rdp_inst); - pthread_mutex_unlock(&(rdp_client->rdp_lock)); /* Close connection cleanly if server is disconnecting */ if (connection_closing) @@ -497,8 +488,6 @@ static int guac_rdp_handle_connection(guac_client* client) { guac_rdp_print_job_free(rdp_client->active_job); } - pthread_mutex_lock(&(rdp_client->rdp_lock)); - /* Disconnect client and channels */ freerdp_disconnect(rdp_inst); @@ -521,8 +510,6 @@ static int guac_rdp_handle_connection(guac_client* client) { /* Free display */ guac_common_display_free(rdp_client->display); - pthread_mutex_unlock(&(rdp_client->rdp_lock)); - /* Client is now disconnected */ guac_client_log(client, GUAC_LOG_INFO, "Internal RDP client disconnected"); diff --git a/src/protocols/rdp/rdp.h b/src/protocols/rdp/rdp.h index 5220a6c2..5394bb36 100644 --- a/src/protocols/rdp/rdp.h +++ b/src/protocols/rdp/rdp.h @@ -153,13 +153,6 @@ typedef struct guac_rdp_client { */ guac_common_list* available_svc; - /** - * Lock which is locked and unlocked for each RDP message, and for each - * part of the RDP client instance which may be dynamically freed and - * reallocated during reconnection. - */ - pthread_mutex_t rdp_lock; - /** * Common attributes for locks. */