aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <guskraro@student.gu.se>2017-10-04 14:48:45 +0200
committerRobin Krahl <guskraro@student.gu.se>2017-10-04 14:49:04 +0200
commit0937e53f4a33bb9a55c4ab4cf6c31a3294cf483c (patch)
tree0d9c20aef7c72854d9c1ce762bd057a2f63dd579
parent303be924d87e699bc21029fc71fd97cc676b88e3 (diff)
downloadmidbro-0937e53f4a33bb9a55c4ab4cf6c31a3294cf483c.tar.gz
midbro-0937e53f4a33bb9a55c4ab4cf6c31a3294cf483c.tar.bz2
fifoqueue: Release (or do not acquire) mutex in all cases in add_to_queue
-rw-r--r--broccoli/src/fifoqueue.c8
1 files 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));