• Home
  • Raw
  • Download

Lines Matching refs:rate_limiting

119 	tick = ev_token_bucket_get_tick(&now, bev->rate_limiting->cfg);  in bufferevent_update_buckets()
120 if (tick != bev->rate_limiting->limit.last_updated) in bufferevent_update_buckets()
121 ev_token_bucket_update(&bev->rate_limiting->limit, in bufferevent_update_buckets()
122 bev->rate_limiting->cfg, tick); in bufferevent_update_buckets()
218 if (!bev->rate_limiting) in _bufferevent_get_rlim_max()
226 if (bev->rate_limiting->cfg) { in _bufferevent_get_rlim_max()
228 max_so_far = LIM(bev->rate_limiting->limit); in _bufferevent_get_rlim_max()
230 if (bev->rate_limiting->group) { in _bufferevent_get_rlim_max()
232 bev->rate_limiting->group; in _bufferevent_get_rlim_max()
280 if (!bev->rate_limiting) in _bufferevent_decrement_read_buckets()
283 if (bev->rate_limiting->cfg) { in _bufferevent_decrement_read_buckets()
284 bev->rate_limiting->limit.read_limit -= bytes; in _bufferevent_decrement_read_buckets()
285 if (bev->rate_limiting->limit.read_limit <= 0) { in _bufferevent_decrement_read_buckets()
287 if (event_add(&bev->rate_limiting->refill_bucket_event, in _bufferevent_decrement_read_buckets()
288 &bev->rate_limiting->cfg->tick_timeout) < 0) in _bufferevent_decrement_read_buckets()
292 event_del(&bev->rate_limiting->refill_bucket_event); in _bufferevent_decrement_read_buckets()
297 if (bev->rate_limiting->group) { in _bufferevent_decrement_read_buckets()
298 LOCK_GROUP(bev->rate_limiting->group); in _bufferevent_decrement_read_buckets()
299 bev->rate_limiting->group->rate_limit.read_limit -= bytes; in _bufferevent_decrement_read_buckets()
300 bev->rate_limiting->group->total_read += bytes; in _bufferevent_decrement_read_buckets()
301 if (bev->rate_limiting->group->rate_limit.read_limit <= 0) { in _bufferevent_decrement_read_buckets()
302 _bev_group_suspend_reading(bev->rate_limiting->group); in _bufferevent_decrement_read_buckets()
303 } else if (bev->rate_limiting->group->read_suspended) { in _bufferevent_decrement_read_buckets()
304 _bev_group_unsuspend_reading(bev->rate_limiting->group); in _bufferevent_decrement_read_buckets()
306 UNLOCK_GROUP(bev->rate_limiting->group); in _bufferevent_decrement_read_buckets()
318 if (!bev->rate_limiting) in _bufferevent_decrement_write_buckets()
321 if (bev->rate_limiting->cfg) { in _bufferevent_decrement_write_buckets()
322 bev->rate_limiting->limit.write_limit -= bytes; in _bufferevent_decrement_write_buckets()
323 if (bev->rate_limiting->limit.write_limit <= 0) { in _bufferevent_decrement_write_buckets()
325 if (event_add(&bev->rate_limiting->refill_bucket_event, in _bufferevent_decrement_write_buckets()
326 &bev->rate_limiting->cfg->tick_timeout) < 0) in _bufferevent_decrement_write_buckets()
330 event_del(&bev->rate_limiting->refill_bucket_event); in _bufferevent_decrement_write_buckets()
335 if (bev->rate_limiting->group) { in _bufferevent_decrement_write_buckets()
336 LOCK_GROUP(bev->rate_limiting->group); in _bufferevent_decrement_write_buckets()
337 bev->rate_limiting->group->rate_limit.write_limit -= bytes; in _bufferevent_decrement_write_buckets()
338 bev->rate_limiting->group->total_written += bytes; in _bufferevent_decrement_write_buckets()
339 if (bev->rate_limiting->group->rate_limit.write_limit <= 0) { in _bufferevent_decrement_write_buckets()
340 _bev_group_suspend_writing(bev->rate_limiting->group); in _bufferevent_decrement_write_buckets()
341 } else if (bev->rate_limiting->group->write_suspended) { in _bufferevent_decrement_write_buckets()
342 _bev_group_unsuspend_writing(bev->rate_limiting->group); in _bufferevent_decrement_write_buckets()
344 UNLOCK_GROUP(bev->rate_limiting->group); in _bufferevent_decrement_write_buckets()
365 TAILQ_FOREACH(bev, &g->members, rate_limiting->next_in_group) { in _bev_group_suspend_reading()
383 TAILQ_FOREACH(bev, &g->members, rate_limiting->next_in_group) { in _bev_group_suspend_writing()
403 if (!bev->rate_limiting || !bev->rate_limiting->cfg) { in _bev_refill_callback()
411 bev->rate_limiting->cfg); in _bev_refill_callback()
412 ev_token_bucket_update(&bev->rate_limiting->limit, in _bev_refill_callback()
413 bev->rate_limiting->cfg, in _bev_refill_callback()
418 if (bev->rate_limiting->limit.read_limit > 0) in _bev_refill_callback()
424 if (bev->rate_limiting->limit.write_limit > 0) in _bev_refill_callback()
437 event_add(&bev->rate_limiting->refill_bucket_event, in _bev_refill_callback()
438 &bev->rate_limiting->cfg->tick_timeout); in _bev_refill_callback()
461 bev = TAILQ_NEXT(bev, rate_limiting->next_in_group); in _bev_group_random_element()
477 bev = TAILQ_NEXT(bev, rate_limiting->next_in_group)) { \
481 bev = TAILQ_NEXT(bev, rate_limiting->next_in_group)) { \
574 if (bevp->rate_limiting) { in bufferevent_set_rate_limit()
575 rlim = bevp->rate_limiting; in bufferevent_set_rate_limit()
589 if (bevp->rate_limiting && bevp->rate_limiting->cfg == cfg) { in bufferevent_set_rate_limit()
594 if (bevp->rate_limiting == NULL) { in bufferevent_set_rate_limit()
598 bevp->rate_limiting = rlim; in bufferevent_set_rate_limit()
600 rlim = bevp->rate_limiting; in bufferevent_set_rate_limit()
740 if (!bevp->rate_limiting) { in bufferevent_add_to_rate_limit_group()
749 bevp->rate_limiting = rlim; in bufferevent_add_to_rate_limit_group()
752 if (bevp->rate_limiting->group == g) { in bufferevent_add_to_rate_limit_group()
756 if (bevp->rate_limiting->group) in bufferevent_add_to_rate_limit_group()
760 bevp->rate_limiting->group = g; in bufferevent_add_to_rate_limit_group()
762 TAILQ_INSERT_TAIL(&g->members, bevp, rate_limiting->next_in_group); in bufferevent_add_to_rate_limit_group()
791 if (bevp->rate_limiting && bevp->rate_limiting->group) { in bufferevent_remove_from_rate_limit_group_internal()
793 bevp->rate_limiting->group; in bufferevent_remove_from_rate_limit_group_internal()
795 bevp->rate_limiting->group = NULL; in bufferevent_remove_from_rate_limit_group_internal()
797 TAILQ_REMOVE(&g->members, bevp, rate_limiting->next_in_group); in bufferevent_remove_from_rate_limit_group_internal()
824 if (bevp->rate_limiting && bevp->rate_limiting->cfg) { in bufferevent_get_read_limit()
826 r = bevp->rate_limiting->limit.read_limit; in bufferevent_get_read_limit()
843 if (bevp->rate_limiting && bevp->rate_limiting->cfg) { in bufferevent_get_write_limit()
845 r = bevp->rate_limiting->limit.write_limit; in bufferevent_get_write_limit()
908 EVUTIL_ASSERT(bevp->rate_limiting && bevp->rate_limiting->cfg); in bufferevent_decrement_read_limit()
909 old_limit = bevp->rate_limiting->limit.read_limit; in bufferevent_decrement_read_limit()
911 new_limit = (bevp->rate_limiting->limit.read_limit -= decr); in bufferevent_decrement_read_limit()
914 if (event_add(&bevp->rate_limiting->refill_bucket_event, in bufferevent_decrement_read_limit()
915 &bevp->rate_limiting->cfg->tick_timeout) < 0) in bufferevent_decrement_read_limit()
919 event_del(&bevp->rate_limiting->refill_bucket_event); in bufferevent_decrement_read_limit()
937 EVUTIL_ASSERT(bevp->rate_limiting && bevp->rate_limiting->cfg); in bufferevent_decrement_write_limit()
938 old_limit = bevp->rate_limiting->limit.write_limit; in bufferevent_decrement_write_limit()
940 new_limit = (bevp->rate_limiting->limit.write_limit -= decr); in bufferevent_decrement_write_limit()
943 if (event_add(&bevp->rate_limiting->refill_bucket_event, in bufferevent_decrement_write_limit()
944 &bevp->rate_limiting->cfg->tick_timeout) < 0) in bufferevent_decrement_write_limit()
948 event_del(&bevp->rate_limiting->refill_bucket_event); in bufferevent_decrement_write_limit()