X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Ftbf.c;h=b0bcbc16e0bca76a27cce655083bef7b56a52411;hb=77c84c65dc22afe21bc52d95cd3996b8e1c7d065;hp=7e4d474ef82793e4a9fdb08c78f3e6c792b0ad3c;hpb=16f04029db50b765d952cf4cf053d34262a40db1;p=libucw.git diff --git a/ucw/tbf.c b/ucw/tbf.c index 7e4d474e..b0bcbc16 100644 --- 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 +#include 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; } }