diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-11-10 23:51:50 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-11-10 23:51:50 +0300 |
commit | 7763c6cfaecde4c9f1b47bf07966a88f6dd7d71b (patch) | |
tree | 0681be2b3155fb94315f19a3d195932e06bd7ce7 | |
parent | e97ddb4c2b74b6169d193bd9b5398bd364b02721 (diff) | |
download | accel-ppp-7763c6cfaecde4c9f1b47bf07966a88f6dd7d71b.tar.gz accel-ppp-7763c6cfaecde4c9f1b47bf07966a88f6dd7d71b.zip |
radius: disable read handler when put req into wait queue (fixes race conditions)
-rw-r--r-- | accel-pppd/radius/acct.c | 18 | ||||
-rw-r--r-- | accel-pppd/radius/auth.c | 6 | ||||
-rw-r--r-- | accel-pppd/radius/serv.c | 4 |
3 files changed, 16 insertions, 12 deletions
diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c index de8ce28..7ac6e39 100644 --- a/accel-pppd/radius/acct.c +++ b/accel-pppd/radius/acct.c @@ -69,10 +69,10 @@ static void rad_acct_sent(struct rad_req_t *req, int res) __sync_add_and_fetch(&req->serv->stat_interim_sent, 1); - if (!req->hnd.tpd) { + if (!req->hnd.tpd) triton_md_register_handler(req->rpd->ses->ctrl->ctx, &req->hnd); - triton_md_enable_handler(&req->hnd, MD_MODE_READ); - } + + triton_md_enable_handler(&req->hnd, MD_MODE_READ); if (req->timeout.tpd) triton_timer_mod(&req->timeout, 0); @@ -201,10 +201,10 @@ static void rad_acct_start_sent(struct rad_req_t *req, int res) __sync_add_and_fetch(&req->serv->stat_acct_sent, 1); - if (!req->hnd.tpd) { + if (!req->hnd.tpd) triton_md_register_handler(req->rpd->ses->ctrl->ctx, &req->hnd); - triton_md_enable_handler(&req->hnd, MD_MODE_READ); - } + + triton_md_enable_handler(&req->hnd, MD_MODE_READ); if (req->timeout.tpd) triton_timer_mod(&req->timeout, 0); @@ -318,10 +318,10 @@ static void rad_acct_stop_sent(struct rad_req_t *req, int res) __sync_add_and_fetch(&req->serv->stat_acct_sent, 1); - if (!req->hnd.tpd) { + if (!req->hnd.tpd) triton_md_register_handler(req->rpd ? req->rpd->ses->ctrl->ctx : NULL, &req->hnd); - triton_md_enable_handler(&req->hnd, MD_MODE_READ); - } + + triton_md_enable_handler(&req->hnd, MD_MODE_READ); if (req->timeout.tpd) triton_timer_mod(&req->timeout, 0); diff --git a/accel-pppd/radius/auth.c b/accel-pppd/radius/auth.c index 2124c4b..43dec23 100644 --- a/accel-pppd/radius/auth.c +++ b/accel-pppd/radius/auth.c @@ -219,10 +219,10 @@ static void rad_auth_sent(struct rad_req_t *req, int res) __sync_add_and_fetch(&req->serv->stat_auth_sent, 1); - if (!req->hnd.tpd) { + if (!req->hnd.tpd) triton_md_register_handler(req->rpd->ses->ctrl->ctx, &req->hnd); - triton_md_enable_handler(&req->hnd, MD_MODE_READ); - } + + triton_md_enable_handler(&req->hnd, MD_MODE_READ); if (req->timeout.tpd) triton_timer_mod(&req->timeout, 0); diff --git a/accel-pppd/radius/serv.c b/accel-pppd/radius/serv.c index 935caa4..58fc434 100644 --- a/accel-pppd/radius/serv.c +++ b/accel-pppd/radius/serv.c @@ -204,6 +204,10 @@ int rad_server_req_enter(struct rad_req_t *req) req->serv->queue_cnt++; log_ppp_debug("radius(%i): queue %p\n", req->serv->id, req); pthread_mutex_unlock(&req->serv->lock); + + if (req->hnd.tpd) + triton_md_disable_handler(&req->hnd, MD_MODE_READ); + return 0; } |