Lines Matching refs:cfg

50     const struct ev_token_bucket_cfg *cfg,  in ev_token_bucket_init()  argument
60 if (bucket->read_limit > (ev_int64_t) cfg->read_maximum) in ev_token_bucket_init()
61 bucket->read_limit = cfg->read_maximum; in ev_token_bucket_init()
62 if (bucket->write_limit > (ev_int64_t) cfg->write_maximum) in ev_token_bucket_init()
63 bucket->write_limit = cfg->write_maximum; in ev_token_bucket_init()
65 bucket->read_limit = cfg->read_rate; in ev_token_bucket_init()
66 bucket->write_limit = cfg->write_rate; in ev_token_bucket_init()
74 const struct ev_token_bucket_cfg *cfg, in ev_token_bucket_update() argument
95 if ((cfg->read_maximum - bucket->read_limit) / n_ticks < cfg->read_rate) in ev_token_bucket_update()
96 bucket->read_limit = cfg->read_maximum; in ev_token_bucket_update()
98 bucket->read_limit += n_ticks * cfg->read_rate; in ev_token_bucket_update()
101 if ((cfg->write_maximum - bucket->write_limit) / n_ticks < cfg->write_rate) in ev_token_bucket_update()
102 bucket->write_limit = cfg->write_maximum; in ev_token_bucket_update()
104 bucket->write_limit += n_ticks * cfg->write_rate; in ev_token_bucket_update()
119 tick = ev_token_bucket_get_tick(&now, bev->rate_limiting->cfg); in bufferevent_update_buckets()
122 bev->rate_limiting->cfg, tick); in bufferevent_update_buckets()
127 const struct ev_token_bucket_cfg *cfg) in ev_token_bucket_get_tick() argument
138 return (unsigned)(msec / cfg->msec_per_tick); in ev_token_bucket_get_tick()
175 ev_token_bucket_cfg_free(struct ev_token_bucket_cfg *cfg) in ev_token_bucket_cfg_free() argument
177 mm_free(cfg); in ev_token_bucket_cfg_free()
226 if (bev->rate_limiting->cfg) { in _bufferevent_get_rlim_max()
283 if (bev->rate_limiting->cfg) { in _bufferevent_decrement_read_buckets()
288 &bev->rate_limiting->cfg->tick_timeout) < 0) in _bufferevent_decrement_read_buckets()
321 if (bev->rate_limiting->cfg) { in _bufferevent_decrement_write_buckets()
326 &bev->rate_limiting->cfg->tick_timeout) < 0) in _bufferevent_decrement_write_buckets()
403 if (!bev->rate_limiting || !bev->rate_limiting->cfg) { in _bev_refill_callback()
411 bev->rate_limiting->cfg); in _bev_refill_callback()
413 bev->rate_limiting->cfg, in _bev_refill_callback()
438 &bev->rate_limiting->cfg->tick_timeout); in _bev_refill_callback()
560 struct ev_token_bucket_cfg *cfg) in bufferevent_set_rate_limit() argument
573 if (cfg == NULL) { in bufferevent_set_rate_limit()
576 rlim->cfg = NULL; in bufferevent_set_rate_limit()
587 tick = ev_token_bucket_get_tick(&now, cfg); in bufferevent_set_rate_limit()
589 if (bevp->rate_limiting && bevp->rate_limiting->cfg == cfg) { in bufferevent_set_rate_limit()
602 reinit = rlim->cfg != NULL; in bufferevent_set_rate_limit()
604 rlim->cfg = cfg; in bufferevent_set_rate_limit()
605 ev_token_bucket_init(&rlim->limit, cfg, tick, reinit); in bufferevent_set_rate_limit()
628 event_add(&rlim->refill_bucket_event, &cfg->tick_timeout); in bufferevent_set_rate_limit()
639 const struct ev_token_bucket_cfg *cfg) in bufferevent_rate_limit_group_new() argument
646 tick = ev_token_bucket_get_tick(&now, cfg); in bufferevent_rate_limit_group_new()
651 memcpy(&g->rate_limit_cfg, cfg, sizeof(g->rate_limit_cfg)); in bufferevent_rate_limit_group_new()
654 ev_token_bucket_init(&g->rate_limit, cfg, tick, 0); in bufferevent_rate_limit_group_new()
659 event_add(&g->master_refill_event, &cfg->tick_timeout); in bufferevent_rate_limit_group_new()
671 const struct ev_token_bucket_cfg *cfg) in bufferevent_rate_limit_group_set_cfg() argument
674 if (!g || !cfg) in bufferevent_rate_limit_group_set_cfg()
679 &g->rate_limit_cfg.tick_timeout, &cfg->tick_timeout, ==); in bufferevent_rate_limit_group_set_cfg()
680 memcpy(&g->rate_limit_cfg, cfg, sizeof(g->rate_limit_cfg)); in bufferevent_rate_limit_group_set_cfg()
682 if (g->rate_limit.read_limit > (ev_ssize_t)cfg->read_maximum) in bufferevent_rate_limit_group_set_cfg()
683 g->rate_limit.read_limit = cfg->read_maximum; in bufferevent_rate_limit_group_set_cfg()
684 if (g->rate_limit.write_limit > (ev_ssize_t)cfg->write_maximum) in bufferevent_rate_limit_group_set_cfg()
685 g->rate_limit.write_limit = cfg->write_maximum; in bufferevent_rate_limit_group_set_cfg()
689 event_add(&g->master_refill_event, &cfg->tick_timeout); in bufferevent_rate_limit_group_set_cfg()
824 if (bevp->rate_limiting && bevp->rate_limiting->cfg) { in bufferevent_get_read_limit()
843 if (bevp->rate_limiting && bevp->rate_limiting->cfg) { in bufferevent_get_write_limit()
908 EVUTIL_ASSERT(bevp->rate_limiting && bevp->rate_limiting->cfg); in bufferevent_decrement_read_limit()
915 &bevp->rate_limiting->cfg->tick_timeout) < 0) in bufferevent_decrement_read_limit()
937 EVUTIL_ASSERT(bevp->rate_limiting && bevp->rate_limiting->cfg); in bufferevent_decrement_write_limit()
944 &bevp->rate_limiting->cfg->tick_timeout) < 0) in bufferevent_decrement_write_limit()