summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c6
-rw-r--r--accel-pppd/include/ap_session.h3
-rw-r--r--accel-pppd/ppp/ppp.c30
-rw-r--r--accel-pppd/ppp/ppp.h2
-rw-r--r--accel-pppd/session.c17
5 files changed, 36 insertions, 22 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 94ce485..59ea87f 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -1154,7 +1154,7 @@ static void ipoe_session_terminated_pkt(struct dhcpv4_packet *pack)
ipoe_session_terminated(ses);
}
-static void ipoe_session_terminate(struct ap_session *s, int hard)
+static int ipoe_session_terminate(struct ap_session *s, int hard)
{
struct ipoe_session *ses = container_of(s, typeof(*ses), ses);
@@ -1162,6 +1162,8 @@ static void ipoe_session_terminate(struct ap_session *s, int hard)
ipoe_session_terminated(ses);
else
ses->terminate = 1;
+
+ return 0;
}
@@ -3156,7 +3158,7 @@ static void load_config(void)
if (opt)
conf_lease_timeout = atoi(opt);
else
- conf_lease_timeout = 660;
+ conf_lease_timeout = conf_lease_time;
opt = conf_get_opt("ipoe", "unit-cache");
if (opt)
diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h
index 41155f1..8bfe4cd 100644
--- a/accel-pppd/include/ap_session.h
+++ b/accel-pppd/include/ap_session.h
@@ -50,7 +50,7 @@ struct ap_ctrl
int ppp:1;
void (*started)(struct ap_session*);
void (*finished)(struct ap_session *);
- void (*terminate)(struct ap_session *, int hard);
+ int (*terminate)(struct ap_session *, int hard);
};
struct ap_private
@@ -92,6 +92,7 @@ struct ap_session
int terminating:1;
int terminated:1;
+ int down:1;
int terminate_cause;
struct list_head pd_list;
diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c
index 3a3b2fc..c47d8d9 100644
--- a/accel-pppd/ppp/ppp.c
+++ b/accel-pppd/ppp/ppp.c
@@ -236,13 +236,11 @@ static void destroy_ppp_channel(struct ppp_t *ppp)
static void destablish_ppp(struct ppp_t *ppp)
{
- struct pppunit_cache *uc;
+ struct pppunit_cache *uc = NULL;
if (ppp->unit_fd < 0)
goto destroy_channel;
- triton_event_fire(EV_SES_PRE_FINISHED, &ppp->ses);
-
if (conf_unit_cache) {
struct ifreq ifr;
@@ -256,15 +254,10 @@ static void destablish_ppp(struct ppp_t *ppp)
}
triton_md_unregister_handler(&ppp->unit_hnd, 0);
+
uc = mempool_alloc(uc_pool);
uc->fd = ppp->unit_fd;
uc->unit_idx = ppp->ses.unit_idx;
-
- pthread_mutex_lock(&uc_lock);
- list_add_tail(&uc->entry, &uc_list);
- if (++uc_size > conf_unit_cache)
- pthread_cond_signal(&uc_cond);
- pthread_mutex_unlock(&uc_lock);
} else
triton_md_unregister_handler(&ppp->unit_hnd, 1);
@@ -275,6 +268,14 @@ skip:
destroy_channel:
destroy_ppp_channel(ppp);
+
+ if (uc) {
+ pthread_mutex_lock(&uc_lock);
+ list_add_tail(&uc->entry, &uc_list);
+ if (++uc_size > conf_unit_cache)
+ pthread_cond_signal(&uc_cond);
+ pthread_mutex_unlock(&uc_lock);
+ }
}
static void *uc_thread(void *unused)
@@ -524,7 +525,7 @@ void __export ppp_layer_finished(struct ppp_t *ppp, struct ppp_layer_data_t *d)
destablish_ppp(ppp);
}
-void __export ppp_terminate(struct ap_session *ses, int hard)
+int __export ppp_terminate(struct ap_session *ses, int hard)
{
struct ppp_t *ppp = container_of(ses, typeof(*ppp), ses);
struct layer_node_t *n;
@@ -533,7 +534,7 @@ void __export ppp_terminate(struct ap_session *ses, int hard)
if (hard) {
destablish_ppp(ppp);
- return;
+ return 0;
}
list_for_each_entry(n,&ppp->layers,entry) {
@@ -544,10 +545,11 @@ void __export ppp_terminate(struct ap_session *ses, int hard)
}
}
}
- if (s)
- return;
- destablish_ppp(ppp);
+ if (!s)
+ destablish_ppp(ppp);
+
+ return 1;
}
void __export ppp_register_chan_handler(struct ppp_t *ppp,struct ppp_handler_t *h)
diff --git a/accel-pppd/ppp/ppp.h b/accel-pppd/ppp/ppp.h
index dfceacc..f0fbcd3 100644
--- a/accel-pppd/ppp/ppp.h
+++ b/accel-pppd/ppp/ppp.h
@@ -106,7 +106,7 @@ void ppp_layer_started(struct ppp_t *ppp,struct ppp_layer_data_t*);
void ppp_layer_finished(struct ppp_t *ppp,struct ppp_layer_data_t*);
void ppp_layer_passive(struct ppp_t *ppp,struct ppp_layer_data_t*);
-void ppp_terminate(struct ap_session *ses, int hard);
+int ppp_terminate(struct ap_session *ses, int hard);
void ppp_register_chan_handler(struct ppp_t *, struct ppp_handler_t *);
void ppp_register_unit_handler(struct ppp_t * ,struct ppp_handler_t *);
diff --git a/accel-pppd/session.c b/accel-pppd/session.c
index da18e43..247c0d7 100644
--- a/accel-pppd/session.c
+++ b/accel-pppd/session.c
@@ -173,6 +173,13 @@ void __export ap_session_finished(struct ap_session *ses)
{
ses->terminated = 1;
+ if (!ses->down) {
+ ap_session_ifdown(ses);
+ ap_session_read_stats(ses, NULL);
+
+ triton_event_fire(EV_SES_FINISHING, ses);
+ }
+
triton_event_fire(EV_SES_PRE_FINISHED, ses);
pthread_rwlock_wrlock(&ses_lock);
@@ -275,12 +282,14 @@ void __export ap_session_terminate(struct ap_session *ses, int cause, int hard)
log_ppp_debug("terminate\n");
- ap_session_ifdown(ses);
- ap_session_read_stats(ses, NULL);
+ if (ses->ctrl->terminate(ses, hard)) {
+ ap_session_ifdown(ses);
+ ap_session_read_stats(ses, NULL);
- triton_event_fire(EV_SES_FINISHING, ses);
+ triton_event_fire(EV_SES_FINISHING, ses);
- ses->ctrl->terminate(ses, hard);
+ ses->down = 1;
+ }
}
void ap_shutdown_soft(void (*cb)(void))