diff options
-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"); |