From 8df850023c78d7ca0d3c0e8070cfdb56878a7da5 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 4 Mar 2019 10:16:51 +1100 Subject: [PATCH] [c-host] fix deadlock when there is no update --- c-host/app.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/c-host/app.c b/c-host/app.c index 359e0a39..fcee9205 100644 --- a/c-host/app.c +++ b/c-host/app.c @@ -71,8 +71,8 @@ static int pointerThread(void * opaque) pointer->data = app.pointerData; if (!app.iface->getPointer(&pointer)) DEBUG_ERROR("Failed to get the pointer"); - os_signalEvent(app.updateEvent); #endif + os_signalEvent(app.updateEvent); } DEBUG_INFO("Cursor thread stopped"); @@ -303,6 +303,7 @@ int app_main() bool frameUpdate = false; bool pointerUpdate = false; +retry_capture: switch(iface->capture(&frameUpdate, &pointerUpdate)) { case CAPTURE_RESULT_OK: @@ -342,6 +343,9 @@ int app_main() goto finish; } + if (!frameUpdate && !pointerUpdate) + goto retry_capture; + if (frameUpdate && !os_signalEvent(app.frameEvent)) { DEBUG_ERROR("Failed to signal the frame thread");