From: Andre Noll Date: Mon, 28 Dec 2009 21:51:23 +0000 (+0100) Subject: Add btr_bytes_pending(). X-Git-Tag: v0.4.2~250 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=883af94f87f7d5465047c3bdd626a9dca3c2be8c;p=paraslash.git Add btr_bytes_pending(). --- diff --git a/buffer_tree.c b/buffer_tree.c index 084827e3..941d58db 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -196,3 +196,20 @@ size_t btr_get_input_queue_size(struct btr_node *btrn) size += br_available_bytes(br); return size; } + +/** + * Return the size of the largest input queue. + * + * Iterates over all children of the given node. + */ +size_t btr_bytes_pending(struct btr_node *btrn) +{ + size_t max_size = 0; + struct btr_node *ch; + + FOR_EACH_CHILD(ch, btrn) { + size_t size = btr_get_input_queue_size(ch); + max_size = PARA_MAX(max_size, size); + } + return max_size; +} diff --git a/buffer_tree.h b/buffer_tree.h index 8a7a33b8..b066ad9e 100644 --- a/buffer_tree.h +++ b/buffer_tree.h @@ -5,3 +5,4 @@ struct btr_node *btr_new_node(char *name, struct btr_node *parent); void btr_del_node(struct btr_node *btrn); void btr_add_output(char *buf, size_t size, struct btr_node *btrn); bool btr_is_leaf_node(struct btr_node *btrn); +size_t btr_bytes_pending(struct btr_node *btrn);