diff options
Diffstat (limited to 'accel-pppd/radius')
-rw-r--r-- | accel-pppd/radius/radius_p.h | 2 | ||||
-rw-r--r-- | accel-pppd/radius/serv.c | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h index 4654c78d..f6262135 100644 --- a/accel-pppd/radius/radius_p.h +++ b/accel-pppd/radius/radius_p.h @@ -82,6 +82,7 @@ struct rad_server_t { time_t fail_time; int conf_fail_time; int timeout_cnt; + double weight; pthread_mutex_t lock; unsigned long stat_auth_sent; @@ -107,6 +108,7 @@ struct rad_server_t { struct stat_accm_t *stat_interim_query_1m; struct stat_accm_t *stat_interim_query_5m; + int backup:1; int starting:1; int acct_on:1; int need_free:1; diff --git a/accel-pppd/radius/serv.c b/accel-pppd/radius/serv.c index 6a080709..46d064a0 100644 --- a/accel-pppd/radius/serv.c +++ b/accel-pppd/radius/serv.c @@ -63,7 +63,7 @@ static struct rad_server_t *__rad_server_get(int type, struct rad_server_t *excl continue; } - if (s->client_cnt[type] < s0->client_cnt[type]) + if (s0->backup || s->weight*s->client_cnt[type] < s0->weight*s0->client_cnt[type]) s0 = s; } @@ -648,6 +648,18 @@ static int parse_server2(const char *_opt, struct rad_server_t *s) goto out; } else s->conf_fail_time = conf_fail_time; + + ptr3 = strstr(ptr2, ",weight="); + if (ptr3) + s->weight = 1.0/atoi(ptr3 + 8); + else + s->weight = 1; + + ptr3 = strstr(ptr2, ",backup"); + if (ptr3) + s->backup = 1; + else + s->backup = 0; if (ptr2) *ptr2 = 0; |