From 6799d518a5d7716bd85dccb8f3228d5f42a70ce7 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 30 Oct 2020 03:27:28 +1100 Subject: [PATCH] [client] common: added spin timeout to framebuffer wait --- common/src/framebuffer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/src/framebuffer.c b/common/src/framebuffer.c index 39b316ab..37977940 100644 --- a/common/src/framebuffer.c +++ b/common/src/framebuffer.c @@ -39,9 +39,14 @@ const size_t FrameBufferStructSize = sizeof(FrameBuffer); void framebuffer_wait(const FrameBuffer * frame, size_t size) { - while(atomic_load_explicit(&frame->wp, memory_order_acquire) < size) { + while(atomic_load_explicit(&frame->wp, memory_order_acquire) < size) + { + int spinCount = 0; while(frame->wp < size) { + if (++spinCount == FB_SPIN_LIMIT) + return; + usleep(1); } } }