X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Futil-queue.c;h=0dba00b8c8a794f4d4e737500882713694f5cc32;hb=4b7f19c51325601d7e7569e6101c7bfcdf984ef7;hp=f7f6146a728141129869502cab64e5acb240a83a;hpb=07aa8f3c18a33af0961e7546980a63ab5f6fba4f;p=palacios.git diff --git a/linux_module/util-queue.c b/linux_module/util-queue.c index f7f6146..0dba00b 100644 --- a/linux_module/util-queue.c +++ b/linux_module/util-queue.c @@ -13,7 +13,14 @@ void init_queue(struct gen_queue * queue, unsigned int max_entries) { queue->max_entries = max_entries; INIT_LIST_HEAD(&(queue->entries)); - spin_lock_init(&(queue->lock)); + palacios_spinlock_init(&(queue->lock)); +} + +void deinit_queue(struct gen_queue * queue) { + while (dequeue(queue)) { + ERROR("Freeing non-empty queue. PROBABLE MEMORY LEAK DETECTED\n"); + } + palacios_spinlock_deinit(&(queue->lock)); } struct gen_queue * create_queue(unsigned int max_entries) { @@ -41,13 +48,13 @@ int enqueue(struct gen_queue * queue, void * entry) { return -1; } - spin_lock_irqsave(&(queue->lock), flags); + palacios_spinlock_lock_irqsave(&(queue->lock), flags); q_entry->entry = entry; list_add_tail(&(q_entry->node), &(queue->entries)); queue->num_entries++; - spin_unlock_irqrestore(&(queue->lock), flags); + palacios_spinlock_unlock_irqrestore(&(queue->lock), flags); return 0; } @@ -57,7 +64,7 @@ void * dequeue(struct gen_queue * queue) { void * entry_val = 0; unsigned long flags; - spin_lock_irqsave(&(queue->lock), flags); + palacios_spinlock_lock_irqsave(&(queue->lock), flags); if (!list_empty(&(queue->entries))) { struct list_head * q_entry = queue->entries.next; @@ -71,7 +78,7 @@ void * dequeue(struct gen_queue * queue) { } - spin_unlock_irqrestore(&(queue->lock), flags); + palacios_spinlock_unlock_irqrestore(&(queue->lock), flags); return entry_val; }