diff options
-rw-r--r-- | accel-pppd/shaper/shaper.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c index d69af3e5..3628bc5a 100644 --- a/accel-pppd/shaper/shaper.c +++ b/accel-pppd/shaper/shaper.c @@ -56,7 +56,8 @@ static pthread_rwlock_t shaper_lock = PTHREAD_RWLOCK_INITIALIZER; static LIST_HEAD(shaper_list); struct time_range_pd_t; -struct shaper_pd_t { +struct shaper_pd_t +{ struct list_head entry; struct ppp_t *ppp; struct ppp_pd_t pd; @@ -66,10 +67,10 @@ struct shaper_pd_t { int up_speed; struct list_head tr_list; struct time_range_pd_t *cur_tr; - int refs; }; -struct time_range_pd_t { +struct time_range_pd_t +{ struct list_head entry; int id; int down_speed; @@ -78,7 +79,8 @@ struct time_range_pd_t { int up_burst; }; -struct time_range_t { +struct time_range_t +{ struct list_head entry; int id; struct triton_timer_t begin; @@ -120,7 +122,6 @@ static struct shaper_pd_t *find_pd(struct ppp_t *ppp, int create) list_add_tail(&spd->pd.entry, &ppp->pd_list); spd->pd.key = &pd_key; INIT_LIST_HEAD(&spd->tr_list); - spd->refs = 1; pthread_rwlock_wrlock(&shaper_lock); list_add_tail(&spd->entry, &shaper_list); @@ -431,6 +432,7 @@ static void ev_ppp_finishing(struct ppp_t *ppp) struct shaper_pd_t *pd = find_pd(ppp, 0); if (pd) { + clear_tr_pd(pd); pthread_rwlock_wrlock(&shaper_lock); list_del(&pd->entry); pthread_rwlock_unlock(&shaper_lock); @@ -439,11 +441,7 @@ static void ev_ppp_finishing(struct ppp_t *ppp) if (pd->down_speed || pd->up_speed) remove_limiter(ppp); - if (--pd->refs == 0) { - clear_tr_pd(pd); - _free(pd); - } else - pd->ppp = NULL; + _free(pd); } } @@ -627,8 +625,8 @@ static void update_shaper_tr(struct shaper_pd_t *pd) { struct time_range_pd_t *tr; - if (!pd->ppp || pd->ppp->terminating) - goto out; + if (pd->ppp->terminating) + return; list_for_each_entry(tr, &pd->tr_list, entry) { if (tr->id != time_range_id) @@ -638,11 +636,11 @@ static void update_shaper_tr(struct shaper_pd_t *pd) } if (pd->temp_down_speed || pd->temp_up_speed) - goto out; + return; if (pd->down_speed || pd->up_speed) { if (pd->cur_tr && pd->down_speed == pd->cur_tr->down_speed && pd->up_speed == pd->cur_tr->up_speed) - goto out; + return; remove_limiter(pd->ppp); } @@ -655,13 +653,7 @@ static void update_shaper_tr(struct shaper_pd_t *pd) } } else if (conf_verbose) - log_ppp_info2("shaper: removed shaper\n"); - -out: - if (--pd->refs == 0) { - clear_tr_pd(pd); - _free(pd); - } + log_ppp_info2("shaper: removed shaper\n"); } static void time_range_begin_timer(struct triton_timer_t *t) |