From 0937e53f4a33bb9a55c4ab4cf6c31a3294cf483c Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 4 Oct 2017 14:48:45 +0200 Subject: fifoqueue: Release (or do not acquire) mutex in all cases in add_to_queue --- broccoli/src/fifoqueue.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/broccoli/src/fifoqueue.c b/broccoli/src/fifoqueue.c index 9b972e7..87e0332 100644 --- a/broccoli/src/fifoqueue.c +++ b/broccoli/src/fifoqueue.c @@ -48,13 +48,13 @@ is_empty(Fifo_q * q) int add_to_queue(Fifo_q * q, Sensor_t * sensor) { + if (q == NULL) + return -1; pthread_mutex_lock(&lock); /* TODO delete first one if full */ - if(q == NULL){ - return -1; - } - else if(is_full(q)){ + if(is_full(q)){ + pthread_mutex_unlock(&lock); return -1; } Queue_t * new_elem = (Queue_t *) malloc(sizeof(Queue_t)); -- cgit v1.2.1