From: Martin Mares Date: Sat, 21 Feb 2009 19:29:10 +0000 (+0100) Subject: Logging: Let TBF report the number of dropped messages. X-Git-Tag: holmes-import~43 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=ec69802864ba3b2a3b22f12f29bb8fe867dd1a22;p=libucw.git Logging: Let TBF report the number of dropped messages. --- diff --git a/ucw/tbf.c b/ucw/tbf.c index 7e4d474e..9f8404e1 100644 --- a/ucw/tbf.c +++ b/ucw/tbf.c @@ -29,13 +29,16 @@ tbf_limit(struct token_bucket_filter *f, timestamp_t now) b = MIN(b, f->burst); if (b >= 1) { + uns dropped = f->drop_count; f->bucket = b - 1; - return 1; + f->drop_count = 0; + return dropped; } else { f->bucket = b; - return 0; + f->drop_count++; + return -f->drop_count; } } diff --git a/ucw/tbf.h b/ucw/tbf.h index 14154791..5610090b 100644 --- a/ucw/tbf.h +++ b/ucw/tbf.h @@ -15,6 +15,7 @@ struct token_bucket_filter { uns burst; // Capacity of the bucket timestamp_t last_hit; // Internal state... double bucket; + uns drop_count; }; void tbf_init(struct token_bucket_filter *f);