summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel-pppd/CMakeLists.txt8
-rw-r--r--accel-pppd/cli/std_cmd.c39
-rw-r--r--accel-pppd/main.c37
3 files changed, 53 insertions, 31 deletions
diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt
index ff2cfe0e..505beed3 100644
--- a/accel-pppd/CMakeLists.txt
+++ b/accel-pppd/CMakeLists.txt
@@ -16,10 +16,10 @@ ELSE (SESSIONID_LEN)
ADD_DEFINITIONS(-DAP_SESSIONID_LEN=16)
ENDIF (SESSIONID_LEN)
-IF (BACKUP)
- ADD_DEFINITIONS(-DUSE_BACKUP)
- ADD_SUBDIRECTORY(backup)
-ENDIF (BACKUP)
+#IF (BACKUP)
+# ADD_DEFINITIONS(-DUSE_BACKUP)
+# ADD_SUBDIRECTORY(backup)
+#ENDIF (BACKUP)
IF (NOT DEFINED RADIUS)
SET(RADIUS TRUE)
diff --git a/accel-pppd/cli/std_cmd.c b/accel-pppd/cli/std_cmd.c
index 2f5af8aa..62327f92 100644
--- a/accel-pppd/cli/std_cmd.c
+++ b/accel-pppd/cli/std_cmd.c
@@ -341,47 +341,40 @@ static void reload_help(char * const *fields, int fields_cnt, void *client)
//==========================
-static void __do_restart1(void)
-{
- core_restart(1);
-}
-
-static void __do_restart0(void)
-{
- core_restart(0);
-}
-
-
static int restart_exec(const char *cmd, char * const *f, int f_cnt, void *cli)
{
- void (*restart)(void);
-
if (f_cnt == 2) {
+#ifdef USE_BACKUP
if (strcmp(f[1], "soft") == 0)
- restart = __do_restart1;
- else if (strcmp(f[1], "gracefully") == 0)
- restart = __do_restart0;
- else if (strcmp(f[1], "hard") == 0)
- core_restart(0);
+ core_restart(1);
else
+#endif
+ if (strcmp(f[1], "hard") == 0) {
+ terminate_all_sessions(1);
+ core_restart(0);
+ return CLI_CMD_OK;
+ } else
return CLI_CMD_SYNTAX;
} else if (f_cnt == 1)
- restart = __do_restart1;
+ core_restart(0);
else
return CLI_CMD_SYNTAX;
- ap_shutdown_soft(restart, 0);
- terminate_all_sessions(0);
+ core_restart(0);
return CLI_CMD_OK;
}
static void restart_help(char * const *fields, int fields_cnt, void *client)
{
- cli_send(client, "restart [soft|gracefully|hard] - restart daemon\r\n");
+#ifdef USE_BACKUP
+ cli_send(client, "restart [soft|hard] - restart daemon\r\n");
cli_send(client, "\t\tsoft - restart daemon softly, e.g. keep existing connections if session backup is enabled (default)\r\n");
- cli_send(client, "\t\tgracefully - terminate all connections then restart\r\n");
+#else
+ cli_send(client, "restart [hard] - restart daemon\r\n");
+#endif
cli_send(client, "\t\thard - restart immediatly\r\n");
+ cli_send(client, "\t\tdefault action - terminate all connections then restart\r\n");
}
diff --git a/accel-pppd/main.c b/accel-pppd/main.c
index 66737248..02ada1d1 100644
--- a/accel-pppd/main.c
+++ b/accel-pppd/main.c
@@ -37,6 +37,10 @@ static char *conf_dump;
static sigset_t orig_set;
static char **argv;
static int argc;
+static int restart = -1;
+static int term;
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
#ifdef CRYPTO_OPENSSL
#include <openssl/ssl.h>
@@ -131,7 +135,7 @@ static void close_all_fd(void)
closedir(dirp);
}
-void core_restart(int soft)
+static void __core_restart(int soft)
{
char exe[PATH_MAX];
@@ -153,6 +157,16 @@ void core_restart(int soft)
}
}
+void core_restart(int soft)
+{
+#ifdef USE_BACKUP
+ if (soft)
+ __core_restart(1);
+#endif
+ restart = soft;
+ kill(getpid(), SIGTERM);
+}
+
static void sigsegv(int num)
{
char cmd[PATH_MAX];
@@ -191,7 +205,7 @@ out:
pid = fork();
if (pid) {
waitpid(pid, &status, 0);
- core_restart(1);
+ __core_restart(1);
}
if (conf_dump) {
@@ -204,6 +218,14 @@ out:
abort();
}
+static void shutdown_cb()
+{
+ pthread_mutex_lock(&lock);
+ term = 1;
+ pthread_cond_signal(&cond);
+ pthread_mutex_unlock(&lock);
+}
+
int main(int _argc, char **_argv)
{
sigset_t set;
@@ -336,11 +358,18 @@ int main(int _argc, char **_argv)
sigwait(&set, &sig);
log_info1("terminate, sig = %i\n", sig);
- if (ap_shutdown_soft(NULL, 1) == 0)
- sigwait(&set, &sig);
+ ap_shutdown_soft(shutdown_cb, 1);
+
+ pthread_mutex_lock(&lock);
+ while (!term)
+ pthread_cond_wait(&cond, &lock);
+ pthread_mutex_unlock(&lock);
triton_terminate();
+ if (restart != -1)
+ __core_restart(restart);
+
if (pid_file)
unlink(pid_file);