]> mj.ucw.cz Git - libucw.git/commitdiff
Logging: Let TBF report the number of dropped messages.
authorMartin Mares <mj@ucw.cz>
Sat, 21 Feb 2009 19:29:10 +0000 (20:29 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 21 Feb 2009 19:29:10 +0000 (20:29 +0100)
ucw/tbf.c
ucw/tbf.h

index 7e4d474ef82793e4a9fdb08c78f3e6c792b0ad3c..9f8404e18dd96fc41b49d8ad9a2ca39e1b7fac80 100644 (file)
--- 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;
     }
 }
 
index 141547913f9cc2459f99bbd602caa55bb1ceab65..5610090bf38b111d9784d958f9d6523ff15786e4 100644 (file)
--- 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);