From 0cae33bf477bd507609c91e1d362736bc5f557bf Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Thu, 10 Aug 2023 11:57:56 +0300 Subject: [PATCH] blockingqueue.hpp: Fix sem_wait not blocking if task is signaled sem_wait() can be interrupted if the task receives a signal, however the blockinglist implementation depends on blocking until the semaphore can be obtained. --- src/include/containers/BlockingQueue.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/containers/BlockingQueue.hpp b/src/include/containers/BlockingQueue.hpp index 3b1ec77a86..7a88b7bdb6 100644 --- a/src/include/containers/BlockingQueue.hpp +++ b/src/include/containers/BlockingQueue.hpp @@ -56,7 +56,7 @@ public: void push(T newItem) { - px4_sem_wait(&_sem_head); + do {} while (px4_sem_wait(&_sem_head) != 0); _data[_tail] = newItem; _tail = (_tail + 1) % N; @@ -66,7 +66,7 @@ public: T pop() { - px4_sem_wait(&_sem_tail); + do {} while (px4_sem_wait(&_sem_tail) != 0); T ret = _data[_head]; _head = (_head + 1) % N;