From d994c8a2f9b764b7bee21affe1b2899e5bbf8514 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 8 Sep 2024 18:12:15 -0700 Subject: [PATCH] GUACAMOLE-377: Restore heuristic detection of VNC frame boundaries. --- src/protocols/vnc/client.h | 2 +- src/protocols/vnc/display.c | 9 --------- src/protocols/vnc/display.h | 11 ----------- src/protocols/vnc/vnc.c | 23 +++++++++++++++-------- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/protocols/vnc/client.h b/src/protocols/vnc/client.h index eec4bfce4..37e3d8c55 100644 --- a/src/protocols/vnc/client.h +++ b/src/protocols/vnc/client.h @@ -32,7 +32,7 @@ * milliseconds. If the server is silent for at least this amount of time, the * frame will be considered finished. */ -#define GUAC_VNC_FRAME_TIMEOUT 0 +#define GUAC_VNC_FRAME_TIMEOUT 16 /** * The amount of time to wait for a new message from the VNC server when diff --git a/src/protocols/vnc/display.c b/src/protocols/vnc/display.c index 93a981b94..f0a670a4e 100644 --- a/src/protocols/vnc/display.c +++ b/src/protocols/vnc/display.c @@ -125,15 +125,6 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { } -void guac_vnc_update_finished(rfbClient* client) { - - guac_client* gc = rfbClientGetClientData(client, GUAC_VNC_CLIENT_KEY); - guac_vnc_client* vnc_client = (guac_vnc_client*) gc->data; - - guac_display_end_multiple_frames(vnc_client->display, 1); - -} - void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) { guac_client* gc = rfbClientGetClientData(client, GUAC_VNC_CLIENT_KEY); diff --git a/src/protocols/vnc/display.h b/src/protocols/vnc/display.h index fd1bcd04d..cd7d27b25 100644 --- a/src/protocols/vnc/display.h +++ b/src/protocols/vnc/display.h @@ -51,17 +51,6 @@ */ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h); -/** - * Callback invoked by libVNCServer when all binary image data for the current - * frame has been received from the VNC server. The image data that frame will - * have been exposed via previous calls to guac_vnc_update(). - * - * @param client - * The VNC client associated with the VNC session in which the new image - * was received. - */ -void guac_vnc_update_finished(rfbClient* client); - /** * Callback invoked by libVNCServer when it receives a CopyRect message. * CopyRect specified a rectangle of source data within the display and a diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index 85f0cbf3c..5361b05f9 100644 --- a/src/protocols/vnc/vnc.c +++ b/src/protocols/vnc/vnc.c @@ -139,7 +139,6 @@ rfbClient* guac_vnc_get_client(guac_client* client) { /* Framebuffer update handler */ rfb_client->GotFrameBufferUpdate = guac_vnc_update; - rfb_client->FinishedFrameBufferUpdate = guac_vnc_update_finished; rfb_client->GotCopyRect = guac_vnc_copyrect; #ifdef ENABLE_VNC_TLS_LOCKING @@ -553,18 +552,26 @@ void* guac_vnc_client_thread(void* data) { if (wait_result == 0) continue; - /* Handle any message received */ - if (!HandleRFBServerMessage(rfb_client)) { - guac_client_abort(client, - GUAC_PROTOCOL_STATUS_UPSTREAM_ERROR, - "Error handling message from VNC server."); - break; - } + do { + + /* Handle any message received */ + if (!HandleRFBServerMessage(rfb_client)) { + guac_client_abort(client, + GUAC_PROTOCOL_STATUS_UPSTREAM_ERROR, + "Error handling message from VNC server."); + break; + } + + wait_result = guac_vnc_wait_for_messages(rfb_client, GUAC_VNC_FRAME_TIMEOUT); + + } while (wait_result > 0); /* If an error occurs, log it and fail */ if (wait_result < 0) guac_client_abort(client, GUAC_PROTOCOL_STATUS_UPSTREAM_ERROR, "Connection closed."); + guac_display_end_frame(vnc_client->display); + } /* Kill client and finish connection */