]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/tbf.c
Resources: Allow res_free(NULL) and res_detach(NULL)
[libucw.git] / ucw / tbf.c
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;
     }
 }