diff options
author | Kozlov Dmitry <dima@server> | 2010-12-06 18:59:54 +0300 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-12-06 18:59:54 +0300 |
commit | f73cb9f4457c40edf787efcf30ea80822381a732 (patch) | |
tree | 059752a75e0fd4847c386db73ffd295065c82516 /accel-pptpd/ctrl | |
parent | deecc72f6a96153d93dccd547177676bc878a3f3 (diff) | |
download | accel-ppp-f73cb9f4457c40edf787efcf30ea80822381a732.tar.gz accel-ppp-f73cb9f4457c40edf787efcf30ea80822381a732.zip |
cli: implemented shutdown command to shutdown daemon
Diffstat (limited to 'accel-pptpd/ctrl')
-rw-r--r-- | accel-pptpd/ctrl/l2tp/l2tp.c | 12 | ||||
-rw-r--r-- | accel-pptpd/ctrl/pppoe/pppoe.c | 18 | ||||
-rw-r--r-- | accel-pptpd/ctrl/pptp/pptp.c | 13 |
3 files changed, 42 insertions, 1 deletions
diff --git a/accel-pptpd/ctrl/l2tp/l2tp.c b/accel-pptpd/ctrl/l2tp/l2tp.c index cb891b6..2a48aa1 100644 --- a/accel-pptpd/ctrl/l2tp/l2tp.c +++ b/accel-pptpd/ctrl/l2tp/l2tp.c @@ -50,6 +50,8 @@ int conf_retransmit = 5; int conf_hello_interval = 60; const char *conf_host_name = "accel-pptp"; +static int shutdown_soft; + static uint32_t stat_active; static uint32_t stat_starting; @@ -638,6 +640,9 @@ static int l2tp_recv_SCCRQ(struct l2tp_serv_t *serv, struct l2tp_packet_t *pack) struct l2tp_attr_t *framing_cap = NULL; struct l2tp_attr_t *router_id = NULL; + if (shutdown_soft) + return 0; + list_for_each_entry(attr, &pack->attrs, entry) { switch (attr->attr->id) { case Protocol_Version: @@ -1107,6 +1112,11 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, return CLI_CMD_OK; } +static void ev_shutdown_soft(void) +{ + shutdown_soft = 1; +} + static void __init l2tp_init(void) { char *opt; @@ -1143,5 +1153,7 @@ static void __init l2tp_init(void) start_udp_server(); cli_register_simple_cmd2(&show_stat_exec, NULL, 2, "show", "stat"); + + triton_event_register_handler(EV_SHUTDOWN_SOFT, (triton_event_func)ev_shutdown_soft); } diff --git a/accel-pptpd/ctrl/pppoe/pppoe.c b/accel-pptpd/ctrl/pppoe/pppoe.c index b5a9189..57342ba 100644 --- a/accel-pptpd/ctrl/pppoe/pppoe.c +++ b/accel-pptpd/ctrl/pppoe/pppoe.c @@ -62,6 +62,8 @@ char *conf_ac_name; int conf_pado_delay; int conf_ifname_in_sid; +static int shutdown_soft; + static mempool_t conn_pool; static mempool_t pado_pool; @@ -628,7 +630,8 @@ static void pado_timer(struct triton_timer_t *t) { struct delayed_pado_t *pado = container_of(t, typeof(*pado), timer); - pppoe_send_PADO(pado->serv, pado->addr, pado->host_uniq, pado->relay_sid, pado->service_name); + if (!shutdown_soft) + pppoe_send_PADO(pado->serv, pado->addr, pado->host_uniq, pado->relay_sid, pado->service_name); free_delayed_pado(pado); } @@ -644,6 +647,9 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size) int n, service_match = 0; struct delayed_pado_t *pado; + if (shutdown_soft) + return; + if (hdr->sid) { log_warn("pppoe: discarding PADI packet (sid is not zero)\n"); return; @@ -737,6 +743,9 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size) int n, service_match = 0; struct pppoe_conn_t *conn; + if (shutdown_soft) + return; + if (!memcmp(ethhdr->h_dest, bc_addr, ETH_ALEN)) { if (conf_verbose) log_warn("pppoe: discard PADR (destination address is broadcast)\n"); @@ -1102,6 +1111,11 @@ static void _server_stop(struct pppoe_serv_t *serv) pthread_mutex_unlock(&serv->lock); } +static void ev_shutdown_soft(void) +{ + shutdown_soft = 1; +} + void pppoe_server_free(struct pppoe_serv_t *serv) { struct delayed_pado_t *pado; @@ -1206,5 +1220,7 @@ static void __init pppoe_init(void) if (!conf_ac_name) conf_ac_name = _strdup("accel-pptp"); + + triton_event_register_handler(EV_SHUTDOWN_SOFT, (triton_event_func)ev_shutdown_soft); } diff --git a/accel-pptpd/ctrl/pptp/pptp.c b/accel-pptpd/ctrl/pptp/pptp.c index f7ffee0..887db37 100644 --- a/accel-pptpd/ctrl/pptp/pptp.c +++ b/accel-pptpd/ctrl/pptp/pptp.c @@ -56,6 +56,7 @@ static int conf_timeout = 5; static int conf_echo_interval = 0; static int conf_echo_failure = 3; static int conf_verbose = 0; +static int shutdown_soft; static mempool_t conn_pool; @@ -617,6 +618,11 @@ static int pptp_connect(struct triton_md_handler_t *h) continue; } + if (shutdown_soft) { + close(sock); + continue; + } + log_info2("pptp: new connection from %s\n", inet_ntoa(addr.sin_addr)); if (iprange_client_check(addr.sin_addr.s_addr)) { @@ -694,6 +700,11 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, return CLI_CMD_OK; } +static void ev_shutdown_soft(void) +{ + shutdown_soft = 1; +} + static void __init pptp_init(void) { struct sockaddr_in addr; @@ -756,5 +767,7 @@ static void __init pptp_init(void) triton_context_wakeup(&serv.ctx); cli_register_simple_cmd2(show_stat_exec, NULL, 2, "show", "stat"); + + triton_event_register_handler(EV_SHUTDOWN_SOFT, (triton_event_func)ev_shutdown_soft); } |