From f85b6418b850a8e0520647fc67890c77d1453298 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 8 Jan 2021 01:18:02 +1100 Subject: [PATCH] [common] linux: stop event signals accumulating after they are serviced --- common/src/platform/linux/event.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/platform/linux/event.c b/common/src/platform/linux/event.c index be3ae569..e9e12f47 100644 --- a/common/src/platform/linux/event.c +++ b/common/src/platform/linux/event.c @@ -87,10 +87,11 @@ bool lgWaitEventAbs(LGEvent * handle, struct timespec * ts) { assert(handle); - bool ret = true; + bool ret = true; + int count = 0; int res; - while(ret && atomic_load(&handle->count) == 0) + while(ret && (count = atomic_load(&handle->count)) == 0) { if (pthread_mutex_lock(&handle->mutex) != 0) { @@ -132,7 +133,7 @@ bool lgWaitEventAbs(LGEvent * handle, struct timespec * ts) } if (ret && handle->autoReset) - atomic_fetch_sub(&handle->count, 1); + atomic_fetch_sub(&handle->count, count); return ret; }