chunk queue: Fix chunk dequeuing.
authorAndre Noll <maan@systemlinux.org>
Mon, 12 Apr 2010 16:04:31 +0000 (18:04 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 12 Apr 2010 16:04:31 +0000 (18:04 +0200)
We missed to update the number of pending bytes when removing
a chunk from the queue.

This patch also clarifies the description of the cq parameter of
cq_dequeue().

Thanks to Gerrit Renker who pointed out this bug.

chunk_queue.c

index fa31718590dd73fad6f034d69ce2a8d7fc299e86..d295b6c0e849cac1657e0fba48b53ee2f5091983 100644 (file)
@@ -80,12 +80,14 @@ struct queued_chunk *cq_peek(struct chunk_queue *cq)
 /**
  * Remove the current chunk from the queue.
  *
 /**
  * Remove the current chunk from the queue.
  *
- * \param cq The chunk to remove.
+ * \param cq The queue to remove from.
  */
 void cq_dequeue(struct chunk_queue *cq)
 {
        struct queued_chunk *qc = cq_peek(cq);
        assert(qc);
  */
 void cq_dequeue(struct chunk_queue *cq)
 {
        struct queued_chunk *qc = cq_peek(cq);
        assert(qc);
+       assert(cq->num_pending >= qc->num_bytes);
+       cq->num_pending -= qc->num_bytes;
        list_del(&qc->node);
        free(qc);
 }
        list_del(&qc->node);
        free(qc);
 }