]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
priority queue: Set item's idx value to invalid when it's removed from queue.
authorTimo Sirainen <tss@iki.fi>
Mon, 4 Oct 2010 16:16:38 +0000 (17:16 +0100)
committerTimo Sirainen <tss@iki.fi>
Mon, 4 Oct 2010 16:16:38 +0000 (17:16 +0100)
This should assert-crash on double-removes more reliably.

src/lib/priorityq.c

index 7cd297700d259467edd024e9efddcf18ced85e9a..37263ffd258f5f51f2e47f186ef427f2278f5e9a 100644 (file)
@@ -136,6 +136,7 @@ static void priorityq_remove_idx(struct priorityq *pq, unsigned int idx)
 void priorityq_remove(struct priorityq *pq, struct priorityq_item *item)
 {
        priorityq_remove_idx(pq, item->idx);
+       item->idx = -1U;
 }
 
 struct priorityq_item *priorityq_peek(struct priorityq *pq)
@@ -154,8 +155,10 @@ struct priorityq_item *priorityq_pop(struct priorityq *pq)
        struct priorityq_item *item;
 
        item = priorityq_peek(pq);
-       if (item != NULL)
+       if (item != NULL) {
                priorityq_remove_idx(pq, 0);
+               item->idx = -1U;
+       }
        return item;
 }