diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-07-11 15:01:23 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-07-11 15:01:23 +0400 |
commit | 641e9de3e2ccbd7607ffb90e258c02635fe2616b (patch) | |
tree | f8df517d6dd536551f94942c03454505da480182 /accel-pppd/session.c | |
parent | 80c32d237e01b1c05663ccfa34003d2f49aa7eee (diff) | |
download | accel-ppp-641e9de3e2ccbd7607ffb90e258c02635fe2616b.tar.gz accel-ppp-641e9de3e2ccbd7607ffb90e258c02635fe2616b.zip |
futher session backup implementation
cli: introduced 'restart' command to restrat daemon
Diffstat (limited to 'accel-pppd/session.c')
-rw-r--r-- | accel-pppd/session.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/accel-pppd/session.c b/accel-pppd/session.c index d24dcd7..0ca115c 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -39,6 +39,8 @@ static long long unsigned seq; struct ap_session_stat __export ap_session_stat; +static void (*shutdown_cb)(void); + static void generate_sessionid(struct ap_session *ses); void __export ap_session_init(struct ap_session *ses) @@ -139,8 +141,12 @@ void __export ap_session_finished(struct ap_session *ses) ses->backup->storage->free(ses->backup); #endif - if (ap_shutdown && !ap_session_stat.starting && !ap_session_stat.active && !ap_session_stat.finishing) - kill(getpid(), SIGTERM); + if (ap_shutdown && !ap_session_stat.starting && !ap_session_stat.active && !ap_session_stat.finishing) { + if (shutdown_cb) + shutdown_cb(); + else + kill(getpid(), SIGTERM); + } } void __export ap_session_terminate(struct ap_session *ses, int cause, int hard) @@ -178,12 +184,17 @@ void __export ap_session_terminate(struct ap_session *ses, int cause, int hard) ses->ctrl->terminate(ses, hard); } -void ap_shutdown_soft(void) +void ap_shutdown_soft(void (*cb)(void)) { ap_shutdown = 1; + shutdown_cb = cb; - if (!ap_session_stat.starting && !ap_session_stat.active && !ap_session_stat.finishing) - kill(getpid(), SIGTERM); + if (!ap_session_stat.starting && !ap_session_stat.active && !ap_session_stat.finishing) { + if (shutdown_cb) + shutdown_cb(); + else + kill(getpid(), SIGTERM); + } } static void generate_sessionid(struct ap_session *ses) |