Skip to content

if queue is empty return NULL #1

Merged
merged 1 commit into from Apr 2, 2012
+7 −1
View
8 src/queue.c
@@ -51,6 +51,11 @@ QUEUE_ITEM *Get_Queue_Item(QUEUE *queue)
pthread_mutex_lock(&(queue->read_mutex));
pthread_mutex_lock(&(queue->modify_mutex));
+ if(!(qi = pqi = queue->items)) {
+ pthread_mutex_unlock(&(queue->modify_mutex));
+ return (QUEUE_ITEM *)NULL;
+ }
+
qi = pqi = queue->items;
while ((qi->next))
{
@@ -76,4 +81,5 @@ void Free_Queue_Item(QUEUE_ITEM *queue_item)
{
free(queue_item->action);
free(queue_item);
-}
+}
+
Something went wrong with that request. Please try again.