diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-10-23 14:56:26 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-10-23 14:56:26 +0400 |
commit | 744f633e56d88d86cbf16bfa77fe3177d9c71a6b (patch) | |
tree | 137ea274f9fedfdd0ad5d4e3cffcdc4dab41e696 /accel-pppd | |
parent | 2305d7b30b13058efce059fcc7e6f370d43214d3 (diff) | |
download | accel-ppp-744f633e56d88d86cbf16bfa77fe3177d9c71a6b.tar.gz accel-ppp-744f633e56d88d86cbf16bfa77fe3177d9c71a6b.zip |
radius: fixed backup radius selection
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/radius/radius_p.h | 12 | ||||
-rw-r--r-- | accel-pppd/radius/serv.c | 16 |
2 files changed, 17 insertions, 11 deletions
diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h index f656a3e7..7e8b0fd9 100644 --- a/accel-pppd/radius/radius_p.h +++ b/accel-pppd/radius/radius_p.h @@ -106,7 +106,7 @@ struct rad_server_t { time_t fail_time; int conf_fail_time; int timeout_cnt; - double weight; + int weight; pthread_mutex_t lock; unsigned long stat_auth_sent; @@ -132,11 +132,11 @@ 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; - int need_close:1; + unsigned int backup:1; + unsigned int starting:1; + unsigned int acct_on:1; + unsigned int need_free:1; + unsigned int need_close:1; }; #define RAD_SERV_AUTH 0 diff --git a/accel-pppd/radius/serv.c b/accel-pppd/radius/serv.c index b4b423d2..f3594b91 100644 --- a/accel-pppd/radius/serv.c +++ b/accel-pppd/radius/serv.c @@ -64,8 +64,10 @@ static struct rad_server_t *__rad_server_get(int type, struct rad_server_t *excl continue; } - if (s0->backup || s->weight*s->client_cnt[type] < s0->weight*s0->client_cnt[type]) - s0 = s; + if ((s->backup < s0->backup) || + ((s->backup == s0->backup) && + ((s->client_cnt[0] + s->client_cnt[1])/s->weight < (s0->client_cnt[0] + s0->client_cnt[1])/s0->weight))) + s0 = s; } if (s1) @@ -746,9 +748,13 @@ static int parse_server2(const char *_opt, struct rad_server_t *s) s->conf_fail_time = conf_fail_time; ptr3 = strstr(ptr2, ",weight="); - if (ptr3) - s->weight = 1.0/atoi(ptr3 + 8); - else + if (ptr3) { + s->weight = atoi(ptr3 + 8); + if (s->weight <= 0) { + log_error("radius: %s: invalid weight (forced to 1)\n", _opt); + s->weight = 1; + } + } else s->weight = 1; ptr3 = strstr(ptr2, ",backup"); |