]> git.tue.mpg.de Git - paraslash.git/commitdiff
[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 e023bb146071748877aa2643dd414f73e1d78bba..57f1398eeeb441662805b7b36b8c95adde986b78 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 size = 0;
+       size_t size = 0, wrap_consumed = 0;
 
        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);
        }
+       assert(wrap_consumed <= size);
+       size -= wrap_consumed;
        return size;
 }