From 23ef56423c127464216d534fe12a206c807a53d1 Mon Sep 17 00:00:00 2001 From: Kozlov Dmitry Date: Tue, 11 Jun 2013 16:09:42 +0400 Subject: fixed 'restart' commnd (stops all sessions, then do restart) --- accel-pppd/cli/std_cmd.c | 32 ++++++++++++++------------------ accel-pppd/ctrl/ipoe/ipoe.c | 6 +++--- accel-pppd/main.c | 4 ++-- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/accel-pppd/cli/std_cmd.c b/accel-pppd/cli/std_cmd.c index 38198a2f..84a7711c 100644 --- a/accel-pppd/cli/std_cmd.c +++ b/accel-pppd/cli/std_cmd.c @@ -341,41 +341,37 @@ static void reload_help(char * const *fields, int fields_cnt, void *client) //========================== -static void __do_restart(void) +static void __do_restart1(void) { -#ifdef USE_BACKUP - core_restart(0); -#else core_restart(1); -#endif - _exit(0); } +static void __do_restart0(void) +{ + core_restart(0); +} + + static int restart_exec(const char *cmd, char * const *f, int f_cnt, void *cli) { - int hard = 0; + void (*restart)(void); if (f_cnt == 2) { if (strcmp(f[1], "soft") == 0) - hard = 0; + restart = __do_restart1; else if (strcmp(f[1], "gracefully") == 0) - hard = 1; + restart = __do_restart0; else if (strcmp(f[1], "hard") == 0) - __do_restart(); + core_restart(0); else return CLI_CMD_SYNTAX; } else if (f_cnt == 1) - hard = 0; + restart = __do_restart1; else return CLI_CMD_SYNTAX; - if (hard) { - core_restart(1); - _exit(0); - } else { - ap_shutdown_soft(__do_restart); - terminate_all_sessions(0); - } + ap_shutdown_soft(restart); + terminate_all_sessions(0); return CLI_CMD_OK; } diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 3e3a3e8d..e9edd9be 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -533,15 +533,15 @@ static void __ipoe_session_start(struct ipoe_session *ses) if (!ses->siaddr && ses->router != ses->yiaddr) ses->siaddr = ses->router; + if (!ses->siaddr) + find_gw_addr(ses); + if (!ses->siaddr) ses->siaddr = ses->serv->opt_src; if (!ses->siaddr && ses->serv->dhcpv4_relay) ses->siaddr = ses->serv->dhcpv4_relay->giaddr; - if (!ses->siaddr) - find_gw_addr(ses); - if (!ses->siaddr) { log_ppp_error("can't determine Server-ID\n"); ap_session_terminate(&ses->ses, TERM_NAS_ERROR, 0); diff --git a/accel-pppd/main.c b/accel-pppd/main.c index 8a75d5d2..365aee00 100644 --- a/accel-pppd/main.c +++ b/accel-pppd/main.c @@ -148,7 +148,7 @@ void core_restart(int soft) if (fork()) { //close_all_fd(); - return; + _exit(0); } pthread_sigmask(SIG_SETMASK, &orig_set, NULL); @@ -180,7 +180,7 @@ void core_restart(int soft) sprintf(exe, "/proc/%u/exe", getpid()); readlink(exe, exe, PATH_MAX); - if (!f) + if (!f && soft) argv[n++] = "--internal"; argv[n++] = NULL; -- cgit v1.2.3