Fix previous commit by saving file;

This commit is contained in:
Nathan Fisher 2023-11-20 19:10:15 -05:00
parent ddddeebc59
commit 3cb0883b4a

20
mq.c
View file

@ -105,3 +105,23 @@ haggis_msg* haggis_mq_pop(haggis_mq *queue) {
msg->prev = msg->next = NULL;
return msg;
}
haggis_msg* haggis_mq_try_pop(haggis_mq *queue) {
haggis_msg *msg;
if (queue->count == 0)
return NULL;
pthread_mutex_lock(&queue->mutex);
queue->count--;
msg = queue->head;
if (msg->tag == EndOfArchive)
return msg;
if (queue->tail == queue->head) {
queue->tail = queue->head = NULL;
} else {
queue->head = queue->head->prev;
}
pthread_mutex_unlock(&queue->mutex);
msg->prev = msg->next = NULL;
return msg;
}