GUACAMOLE-2063: Merge ensure state flag lock is acquired before checking flag value.

This commit is contained in:
Virtually Nick 2025-05-28 14:14:09 -05:00 committed by GitHub
commit a0c883be58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -141,9 +141,10 @@ static void* guac_display_render_loop(void* data) {
}
/* Use explicit frame boundaries whenever available */
if (render_thread->state.value & GUAC_DISPLAY_RENDER_THREAD_STATE_FRAME_READY) {
if (guac_flag_timedwait_and_lock(&render_thread->state,
GUAC_DISPLAY_RENDER_THREAD_STATE_FRAME_READY, 0)) {
rendered_frames = render_thread->frames;
rendered_frames += render_thread->frames;
render_thread->frames = 0;
guac_flag_clear(&render_thread->state,

View File

@ -139,6 +139,17 @@ int guac_flag_timedwait_and_lock(guac_flag* event_flag,
guac_flag_lock(event_flag);
/* Short path: skip wait completely when possible */
if (!msec_timeout) {
int retval = event_flag->value & flags;
if (!retval)
guac_flag_unlock(event_flag);
return retval;
}
struct timespec ts_timeout;
clock_gettime(CLOCK_MONOTONIC, &ts_timeout);