From a4ec2baf624ee3642b8fcb09d1c30229c8e17f91 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Mon, 16 Oct 2017 15:34:28 +0300 Subject: pppd_compat: do not call ip-down if session was not started --- accel-pppd/extra/pppd_compat.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'accel-pppd/extra') diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c index 03ddf29b..58581899 100644 --- a/accel-pppd/extra/pppd_compat.c +++ b/accel-pppd/extra/pppd_compat.c @@ -262,6 +262,8 @@ static void ev_ses_pre_up(struct ap_session *ses) ap_session_terminate(ses, pd->res > 127 ? TERM_NAS_ERROR : TERM_ADMIN_RESET, 0); return; } + + pd->started = 1; } else if (pid == 0) { sigset_t set; sigfillset(&set); @@ -318,8 +320,6 @@ static void ev_ses_started(struct ap_session *ses) _exit(EXIT_FAILURE); } else log_error("pppd_compat: fork: %s\n", strerror(errno)); - - pd->started = 1; } static void ev_ses_finished(struct ap_session *ses) @@ -335,7 +335,7 @@ static void ev_ses_finished(struct ap_session *ses) if (!pd) return; - if (pd->started) { + if (pd->ip_up_hnd.pid) { pthread_mutex_lock(&pd->ip_up_hnd.lock); if (pd->ip_up_hnd.pid) { log_ppp_warn("pppd_compat: ip-up is not yet finished, terminating it ...\n"); @@ -344,7 +344,7 @@ static void ev_ses_finished(struct ap_session *ses) pthread_mutex_unlock(&pd->ip_up_hnd.lock); } - if (conf_ip_down) { + if (pd->started && conf_ip_down) { argv[4] = ipaddr; argv[5] = peer_ipaddr; fill_argv(argv, pd, conf_ip_down); @@ -379,7 +379,7 @@ static void ev_ses_finished(struct ap_session *ses) log_error("pppd_compat: fork: %s\n", strerror(errno)); } - if (pd->started) { + if (pd->ip_up_hnd.pid) { pthread_mutex_lock(&pd->ip_up_hnd.lock); if (pd->ip_up_hnd.pid) { log_ppp_warn("pppd_compat: ip-up is not yet finished, killing it ...\n"); @@ -736,7 +736,7 @@ static void load_config() if (opt) conf_fork_limit = atoi(opt); else - conf_fork_limit = sysconf(_SC_NPROCESSORS_ONLN*2); + conf_fork_limit = sysconf(_SC_NPROCESSORS_ONLN)*2; } static void init(void) -- cgit v1.2.3