summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-10-06 17:02:45 +0400
committerDmitry Kozlov <xeb@mail.ru>2014-10-06 17:02:45 +0400
commite994bbe0e602b455cc46555f3feccfbee70e685c (patch)
tree148704b0a898808cc00e81a895d1f8d77713cb22
parent43a444fc65d917bf680831c0b942d682d933dc84 (diff)
downloadaccel-ppp-e994bbe0e602b455cc46555f3feccfbee70e685c.tar.gz
accel-ppp-e994bbe0e602b455cc46555f3feccfbee70e685c.zip
radius: fixed Accounting-On/Accounting-Off functionality
-rw-r--r--accel-pppd/radius/radius_p.h1
-rw-r--r--accel-pppd/radius/req.c2
-rw-r--r--accel-pppd/radius/serv.c22
3 files changed, 14 insertions, 11 deletions
diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h
index b76cfcab..f656a3e7 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 0382e165..fb5183bc 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 664c11dd..66931353 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);