From 7f0b0ab1ef9bb43a6e691448af17f3996c8a9f59 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 3 Mar 2016 17:38:13 -0800 Subject: [PATCH] GUAC-1389: Document the frame wait timeout (no magic numbers). --- src/protocols/vnc/client.h | 9 +++++++++ src/protocols/vnc/vnc.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/protocols/vnc/client.h b/src/protocols/vnc/client.h index 36f5870e..316d3883 100644 --- a/src/protocols/vnc/client.h +++ b/src/protocols/vnc/client.h @@ -38,6 +38,15 @@ */ #define GUAC_VNC_FRAME_TIMEOUT 10 +/** + * The amount of time to wait for a new message from the VNC server when + * beginning a new frame. This value must be kept reasonably small such that + * a slow VNC server will not prevent external events from being handled (such + * as the stop signal from guac_client_stop()), but large enough that the + * message handling loop does not eat up CPU spinning. + */ +#define GUAC_VNC_FRAME_START_TIMEOUT 1000000 + /** * The number of milliseconds to wait between connection attempts. */ diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index f192996b..155c9209 100644 --- a/src/protocols/vnc/vnc.c +++ b/src/protocols/vnc/vnc.c @@ -341,7 +341,8 @@ void* guac_vnc_client_thread(void* data) { while (client->state == GUAC_CLIENT_RUNNING) { /* Wait for start of frame */ - int wait_result = guac_vnc_wait_for_messages(rfb_client, 1000000); + int wait_result = guac_vnc_wait_for_messages(rfb_client, + GUAC_VNC_FRAME_START_TIMEOUT); if (wait_result > 0) { guac_timestamp frame_start = guac_timestamp_current();