Adding locks around guac send instructions to resolve client disconnect issue
This commit is contained in:
parent
ea8feac587
commit
bbe552e847
@ -39,6 +39,7 @@
|
||||
#include <time.h>
|
||||
#include <syslog.h>
|
||||
#include <iconv.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
|
||||
@ -132,9 +133,14 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) {
|
||||
|
||||
/* Send cursor data*/
|
||||
surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, w, h, stride);
|
||||
|
||||
pthread_mutex_lock(&(gc->send_lock));
|
||||
|
||||
guac_protocol_send_png(socket,
|
||||
GUAC_COMP_SRC, cursor_layer, 0, 0, surface);
|
||||
|
||||
pthread_mutex_unlock(&(gc->send_lock));
|
||||
|
||||
/* Update cursor */
|
||||
guac_protocol_send_cursor(socket, x, y, cursor_layer, 0, 0, w, h);
|
||||
|
||||
@ -231,8 +237,13 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) {
|
||||
|
||||
/* For now, only use default layer */
|
||||
surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride);
|
||||
|
||||
pthread_mutex_lock(&(gc->send_lock));
|
||||
|
||||
guac_protocol_send_png(socket, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface);
|
||||
|
||||
pthread_mutex_unlock(&(gc->send_lock));
|
||||
|
||||
/* Free surface */
|
||||
cairo_surface_destroy(surface);
|
||||
free(buffer);
|
||||
@ -244,11 +255,15 @@ void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, in
|
||||
guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT);
|
||||
guac_socket* socket = gc->socket;
|
||||
|
||||
pthread_mutex_lock(&(gc->send_lock));
|
||||
|
||||
/* For now, only use default layer */
|
||||
guac_protocol_send_copy(socket,
|
||||
GUAC_DEFAULT_LAYER, src_x, src_y, w, h,
|
||||
GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y);
|
||||
|
||||
pthread_mutex_unlock(&(gc->send_lock));
|
||||
|
||||
((vnc_guac_client_data*) gc->data)->copy_rect_used = 1;
|
||||
|
||||
}
|
||||
@ -301,10 +316,14 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) {
|
||||
guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT);
|
||||
vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data;
|
||||
|
||||
pthread_mutex_lock(&(gc->send_lock));
|
||||
|
||||
/* Send new size */
|
||||
guac_protocol_send_size(gc->socket,
|
||||
GUAC_DEFAULT_LAYER, rfb_client->width, rfb_client->height);
|
||||
|
||||
pthread_mutex_unlock(&(gc->send_lock));
|
||||
|
||||
/* Use original, wrapped proc */
|
||||
return guac_client_data->rfb_MallocFrameBuffer(rfb_client);
|
||||
}
|
||||
@ -317,8 +336,12 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) {
|
||||
/* Convert ASCII character data to UTF-8 */
|
||||
char* utf8_text = convert("ISO_8859-1", "UTF-8", text);
|
||||
|
||||
pthread_mutex_lock(&(gc->send_lock));
|
||||
|
||||
guac_protocol_send_clipboard(socket, utf8_text);
|
||||
|
||||
pthread_mutex_unlock(&(gc->send_lock));
|
||||
|
||||
free(utf8_text);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user