summaryrefslogtreecommitdiff
path: root/accel-pppd/session.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-05-18 01:04:19 +0000
committerDmitry Kozlov <xeb@mail.ru>2014-05-18 02:15:25 +0000
commitd5c3630d92b329735048b228878bb3ae137799cc (patch)
tree2e7ae38e67170ef8f7ce502e40e3d6fbecd06903 /accel-pppd/session.c
parentec41e172a9da0de7cf5c28027928c698d0d1ebf8 (diff)
downloadaccel-ppp-d5c3630d92b329735048b228878bb3ae137799cc.tar.gz
accel-ppp-d5c3630d92b329735048b228878bb3ae137799cc.zip
improved single-session=replace handling
Wait for previous session completely terminated before continuing authorization new session.
Diffstat (limited to 'accel-pppd/session.c')
-rw-r--r--accel-pppd/session.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/accel-pppd/session.c b/accel-pppd/session.c
index c74de57..5d12635 100644
--- a/accel-pppd/session.c
+++ b/accel-pppd/session.c
@@ -159,6 +159,9 @@ void __export ap_session_finished(struct ap_session *ses)
triton_event_fire(EV_SES_FINISHED, ses);
ses->ctrl->finished(ses);
+ if (ses->wakeup)
+ triton_context_wakeup(ses->wakeup);
+
if (ses->username) {
_free(ses->username);
ses->username = NULL;
@@ -310,12 +313,13 @@ static void __terminate_sec(struct ap_session *ses)
ap_session_terminate(ses, TERM_NAS_REQUEST, 0);
}
-int __export ap_session_check_single(const char *username)
+int __export ap_session_set_username(struct ap_session *s, char *username)
{
struct ap_session *ses;
+ int wait = 0;
+ pthread_rwlock_wrlock(&ses_lock);
if (conf_single_session >= 0) {
- pthread_rwlock_rdlock(&ses_lock);
list_for_each_entry(ses, &ses_list, entry) {
if (ses->username && !strcmp(ses->username, username)) {
if (conf_single_session == 0) {
@@ -324,14 +328,23 @@ int __export ap_session_check_single(const char *username)
return -1;
} else {
if (conf_single_session == 1) {
- ap_session_ifdown(ses);
+ if (ses->wakeup)
+ continue;
+ //ap_session_ifdown(ses);
+ ses->wakeup = s->ctrl->ctx;
+ wait = 1;
triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate_sec, ses);
}
}
}
}
- pthread_rwlock_unlock(&ses_lock);
- }
+ s->username = username;
+ } else
+ s->username = username;
+ pthread_rwlock_unlock(&ses_lock);
+
+ if (wait)
+ triton_context_schedule();
return 0;
}