[btr] Fix btr_get_input_queue_size().
authorAndre Noll <maan@systemlinux.org>
Thu, 14 Jan 2010 21:58:54 +0000 (22:58 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 14 Jan 2010 21:58:54 +0000 (22:58 +0100)
We must take care of wrap buffers when computing the input queue size.

buffer_tree.c

index e023bb1..57f1398 100644 (file)
@@ -491,12 +491,17 @@ void btr_remove_node(struct btr_node *btrn)
 size_t btr_get_input_queue_size(struct btr_node *btrn)
 {
        struct btr_buffer_reference *br;
 size_t btr_get_input_queue_size(struct btr_node *btrn)
 {
        struct btr_buffer_reference *br;
-       size_t size = 0;
+       size_t size = 0, wrap_consumed = 0;
 
        FOR_EACH_BUFFER_REF(br, btrn) {
 
        FOR_EACH_BUFFER_REF(br, btrn) {
-               //PARA_CRIT_LOG("size: %zu\n", size);
+               if (br->wrap_count != 0) {
+                       wrap_consumed = br->consumed;
+                       continue;
+               }
                size += br_available_bytes(br);
        }
                size += br_available_bytes(br);
        }
+       assert(wrap_consumed <= size);
+       size -= wrap_consumed;
        return size;
 }
 
        return size;
 }