diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2010-10-26 13:26:54 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2010-10-26 13:26:54 +0400 |
commit | 098a5112a9e2240fdbac3116173f6735ee13dba8 (patch) | |
tree | a539bd790bc8d22d11cd0eab413e9bf2ff53d572 | |
parent | 78b729af58e58dddfc69f22f4a04add7f969451d (diff) | |
download | accel-ppp-098a5112a9e2240fdbac3116173f6735ee13dba8.tar.gz accel-ppp-098a5112a9e2240fdbac3116173f6735ee13dba8.zip |
radius: wait Accounting-Response on accounting start
-rw-r--r-- | accel-pptpd/radius/acct.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/accel-pptpd/radius/acct.c b/accel-pptpd/radius/acct.c index 6703055..0f1b5fd 100644 --- a/accel-pptpd/radius/acct.c +++ b/accel-pptpd/radius/acct.c @@ -131,6 +131,8 @@ static void rad_acct_interim_update(struct triton_timer_t *t) int rad_acct_start(struct radius_pd_t *rpd) { + int i; + rpd->acct_req = rad_req_alloc(rpd, CODE_ACCOUNTING_REQUEST, rpd->ppp->username); if (!rpd->acct_req) { log_emerg("radius: out of memory\n"); @@ -150,8 +152,28 @@ int rad_acct_start(struct radius_pd_t *rpd) if (req_set_RA(rpd->acct_req, conf_acct_secret)) goto out_err; - if (rad_req_send(rpd->acct_req)) + if (rpd->acct_req->reply) { + rad_packet_free(rpd->acct_req->reply); + rpd->acct_req->reply = NULL; + } + + for (i = 0; i < conf_max_try; i++) { + if (rad_req_send(rpd->acct_req)) + goto out_err; + rad_req_wait(rpd->acct_req, conf_timeout); + if (!rpd->acct_req->reply) + continue; + if (rpd->acct_req->reply->id != rpd->acct_req->pack->id || rpd->acct_req->reply->code != CODE_ACCOUNTING_RESPONSE) { + rad_packet_free(rpd->acct_req->reply); + rpd->acct_req->reply = NULL; + } else + break; + } + + if (!rpd->acct_req->reply) { + log_ppp_warn("radius:acct_start: no response\n"); goto out_err; + } rpd->acct_req->hnd.read = rad_acct_read; |