diff options
| author | Dmitry Kozlov <xeb@mail.ru> | 2010-12-19 10:35:14 +0300 |
|---|---|---|
| committer | Dmitry Kozlov <xeb@mail.ru> | 2010-12-19 10:35:14 +0300 |
| commit | aff9ec94d82bb46235da0b4be1b2e5e9c9dafbc2 (patch) | |
| tree | abda301fed7d9851727e5fdd10d7635b6eb3d6cb /accel-pptpd/cli | |
| parent | e8507d40aa9d55eb3af6196584bf3118d4f08050 (diff) | |
| download | accel-ppp-aff9ec94d82bb46235da0b4be1b2e5e9c9dafbc2.tar.gz accel-ppp-aff9ec94d82bb46235da0b4be1b2e5e9c9dafbc2.zip | |
cli: shutdown cancel command
Diffstat (limited to 'accel-pptpd/cli')
| -rw-r--r-- | accel-pptpd/cli/std_cmd.c | 12 | ||||
| -rw-r--r-- | accel-pptpd/cli/telnet.c | 13 |
2 files changed, 20 insertions, 5 deletions
diff --git a/accel-pptpd/cli/std_cmd.c b/accel-pptpd/cli/std_cmd.c index 2ff7728..f7e4b65 100644 --- a/accel-pptpd/cli/std_cmd.c +++ b/accel-pptpd/cli/std_cmd.c @@ -299,10 +299,11 @@ static void terminate_help(char * const *fields, int fields_cnt, void *client) static void shutdown_help(char * const *fields, int fields_cnt, void *client) { - cli_send(client, "shutdown [soft|hard]- shutdown daemon\r\n"); + cli_send(client, "shutdown [soft|hard|cancel]- shutdown daemon\r\n"); cli_send(client, "\t\tdefault action - send termination signals to all clients and wait everybody disconnects\r\n"); cli_send(client, "\t\tsoft - wait until all clients disconnects, don't accept new connections\r\n"); cli_send(client, "\t\thard - shutdown now, don't wait anything\r\n"); + cli_send(client, "\t\tcancel - cancel 'shutdown soft' and return to normal operation\r\n"); } static int shutdown_exec(const char *cmd, char * const *f, int f_cnt, void *cli) @@ -312,15 +313,18 @@ static int shutdown_exec(const char *cmd, char * const *f, int f_cnt, void *cli) if (f_cnt == 2) { if (!strcmp(f[1], "soft")) { - triton_event_fire(EV_SHUTDOWN_SOFT, NULL); + ppp_shutdown_soft(); return CLI_CMD_OK; } else if (!strcmp(f[1], "hard")) hard = 1; - else + else if (!strcmp(f[1], "cancel")) { + ppp_shutdown = 0; + return CLI_CMD_OK; + } else return CLI_CMD_SYNTAX; } - triton_event_fire(EV_SHUTDOWN_SOFT, NULL); + ppp_shutdown_soft(); pthread_rwlock_rdlock(&ppp_lock); list_for_each_entry(ppp, &ppp_list, entry) { diff --git a/accel-pptpd/cli/telnet.c b/accel-pptpd/cli/telnet.c index e46630f..056cb30 100644 --- a/accel-pptpd/cli/telnet.c +++ b/accel-pptpd/cli/telnet.c @@ -14,6 +14,7 @@ #include "triton.h" #include "log.h" +#include "ppp.h" #include "list.h" #include "memdebug.h" @@ -166,7 +167,13 @@ static int cli_client_sendv(struct cli_client_t *tcln, const char *fmt, va_list static int send_banner(struct telnet_client_t *cln) { - return telnet_send(cln, "accel-pptp version " ACCEL_PPTP_VERSION "\r\n", sizeof("accel-pptp version " ACCEL_PPTP_VERSION "\r\n")); + if (telnet_send(cln, "accel-pptp version " ACCEL_PPTP_VERSION "\r\n", sizeof("accel-pptp version " ACCEL_PPTP_VERSION "\r\n"))) + return -1; + if (cln->auth && ppp_shutdown) { + if (telnet_send(cln, "warning: 'shutdown soft' is in progress...\r\n", sizeof("warning: 'shutdown soft' is in progress...\r\n"))) + return -1; + } + return 0; } static int send_config(struct telnet_client_t *cln) @@ -262,6 +269,10 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c) return -1; } cln->auth = 1; + if (ppp_shutdown) { + if (telnet_send(cln, "warning: 'shutdown soft' is in progress...\r\n", sizeof("warning: 'shutdown soft' is in progress...\r\n"))) + return -1; + } } else if (cln->cmdline_len) { b = _malloc(sizeof(*b) + cln->cmdline_len); memcpy(b->buf, cln->cmdline, cln->cmdline_len); |
