From: Andre Noll Date: Thu, 14 Jan 2010 21:58:54 +0000 (+0100) Subject: [btr] Fix btr_get_input_queue_size(). X-Git-Tag: v0.4.2~100 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=5a38ee4a131d881d97c189616a63cf0a12272756;p=paraslash.git [btr] Fix btr_get_input_queue_size(). We must take care of wrap buffers when computing the input queue size. --- diff --git a/buffer_tree.c b/buffer_tree.c index e023bb14..57f1398e 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -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; }