Browse files

Freeing garbage here can be dangerous because another consumer could be

dequeueing at the same time.  However, in this case, there is only ever
one consumer on this fifo (we use mpmc b/c of multiple producers only).
So, actually, it is safe.
  • Loading branch information...
1 parent d006b30 commit 2ea3d833d8bd118ee8ceebb0f4d2fd5a5fc1c196 @postwait postwait committed Aug 9, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 fqd_queue_mem.c
@@ -22,6 +22,8 @@ static fq_msg *queue_mem_dequeue(fqd_queue_impl_data f) {
fq_msg *m;
if(ck_fifo_mpmc_dequeue(&d->q, &m, &garbage) == true) {
+ /* We can free this only because this fifo is used as a
+ * multi-producer and *single* consumer */
if(garbage != d->qhead) free(garbage);
return m;

0 comments on commit 2ea3d83

Please sign in to comment.