From: Nick Mathewson Date: Wed, 4 Aug 2010 19:44:08 +0000 (-0400) Subject: Add an interface to expose min_share in ratelimiting groups X-Git-Tag: release-2.0.6-rc~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ae53d676242227bc199c69de9244d6c3599ab44;p=libevent Add an interface to expose min_share in ratelimiting groups --- diff --git a/bufferevent_ratelim.c b/bufferevent_ratelim.c index afae2e3a..cb8a3bf5 100644 --- a/bufferevent_ratelim.c +++ b/bufferevent_ratelim.c @@ -646,6 +646,14 @@ bufferevent_rate_limit_group_set_cfg( return 0; } +int +bufferevent_rate_limit_group_set_min_share( + struct bufferevent_rate_limit_group *g, + size_t share) +{ + g->min_share = share; + return 0; +} void bufferevent_rate_limit_group_free(struct bufferevent_rate_limit_group *g) diff --git a/include/event2/bufferevent.h b/include/event2/bufferevent.h index 55e44f9c..b87f3a29 100644 --- a/include/event2/bufferevent.h +++ b/include/event2/bufferevent.h @@ -626,6 +626,26 @@ struct bufferevent_rate_limit_group *bufferevent_rate_limit_group_new( int bufferevent_rate_limit_group_set_cfg( struct bufferevent_rate_limit_group *, const struct ev_token_bucket_cfg *); + +/** + Change the smallest quantum we're willing to allocate to any single + bufferevent in a group for reading or writing at a time. + + The rationale is that, because of TCP/IP protocol overheads and kernel + behavior, if a rate-limiting group is so tight on bandwidth that you're + only willing to send 1 byte per tick per bufferevent, you might instead + want to batch up the reads and writes so that you send N bytes per + 1/N of the bufferevents (chosen at random) each tick, so you still wind + up send 1 byte per tick per bufferevent on average, but you don't send + so many tiny packets. + + The default min-share is currently 64 bytes. + + Returns 0 on success, -1 on faulre. + */ +int bufferevent_rate_limit_group_set_min_share( + struct bufferevent_rate_limit_group *, size_t); + /** Free a rate-limiting group. The group must have no members when this function is called.