]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/tbf.c
UCW::CGI: Let url_param_escape() encode non-ASCII characters
[libucw.git] / ucw / tbf.c
index 7e4d474ef82793e4a9fdb08c78f3e6c792b0ad3c..b0bcbc16e0bca76a27cce655083bef7b56a52411 100644 (file)
--- a/ucw/tbf.c
+++ b/ucw/tbf.c
@@ -7,8 +7,8 @@
  *     of the GNU Lesser General Public License.
  */
 
-#include "ucw/lib.h"
-#include "ucw/tbf.h"
+#include <ucw/lib.h>
+#include <ucw/tbf.h>
 
 void
 tbf_init(struct token_bucket_filter *f)
@@ -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;
     }
 }