From e994bbe0e602b455cc46555f3feccfbee70e685c Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Mon, 6 Oct 2014 17:02:45 +0400 Subject: radius: fixed Accounting-On/Accounting-Off functionality --- accel-pppd/radius/radius_p.h | 1 + accel-pppd/radius/req.c | 2 +- accel-pppd/radius/serv.c | 22 ++++++++++++---------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h index b76cfca..f656a3e 100644 --- a/accel-pppd/radius/radius_p.h +++ b/accel-pppd/radius/radius_p.h @@ -177,6 +177,7 @@ struct rad_req_t *rad_req_alloc_empty(); int rad_req_acct_fill(struct rad_req_t *); void rad_req_free(struct rad_req_t *); int rad_req_send(struct rad_req_t *req); +int __rad_req_send(struct rad_req_t *req, int async); int rad_req_read(struct triton_md_handler_t *h); struct radius_pd_t *find_pd(struct ap_session *ses); diff --git a/accel-pppd/radius/req.c b/accel-pppd/radius/req.c index 0382e16..fb5183b 100644 --- a/accel-pppd/radius/req.c +++ b/accel-pppd/radius/req.c @@ -301,7 +301,7 @@ out_err: return -1; } -static int __rad_req_send(struct rad_req_t *req, int async) +int __rad_req_send(struct rad_req_t *req, int async) { if (async == -1) { req->try = conf_max_try - 1; diff --git a/accel-pppd/radius/serv.c b/accel-pppd/radius/serv.c index 664c11d..6693135 100644 --- a/accel-pppd/radius/serv.c +++ b/accel-pppd/radius/serv.c @@ -346,23 +346,25 @@ static void acct_on_timeout(struct triton_timer_t *t) struct rad_req_t *req = container_of(t, typeof(*req), timeout); struct rad_server_t *s = req->serv; - if (!s->starting && ++req->serv->req_cnt == conf_max_try) { + log_switch(triton_context_self(), NULL); + + if (req->try++ == conf_max_try) { rad_req_free(req); - __free_server(s); + if (s->starting) + s->starting = 0; + else + __free_server(s); return; } - req->try = 1; - - rad_req_send(req); + __rad_req_send(req, 0); } static void send_acct_on(struct rad_server_t *s) { - struct rad_req_t *req = _malloc(sizeof(*req)); - - if (!req) - return; + struct rad_req_t *req = rad_req_alloc_empty(); + + log_switch(triton_context_self(), NULL); memset(req, 0, sizeof(*req)); req->hnd.fd = -1; @@ -398,7 +400,7 @@ static void send_acct_on(struct rad_server_t *s) if (req_set_RA(req, s->secret)) goto out_err; - rad_req_send(req); + __rad_req_send(req, 0); triton_timer_add(&s->ctx, &req->timeout, 0); -- cgit v1.2.3