diff options
author | Kozlov Dmitry <dima@server> | 2010-12-27 15:25:38 +0300 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-12-27 15:25:38 +0300 |
commit | 2b34d862111f1fd84cdb9d744ac34c1c933f34da (patch) | |
tree | 1e758ddc96689793e1c4c1b55cf3671bb05f2884 /accel-pptpd/ctrl | |
parent | ccaeb500e38d82c37568292d7850b66691793626 (diff) | |
download | accel-ppp-xebd-2b34d862111f1fd84cdb9d744ac34c1c933f34da.tar.gz accel-ppp-xebd-2b34d862111f1fd84cdb9d744ac34c1c933f34da.zip |
implemented partial config reload via SIGUSR1 signal or cli
Diffstat (limited to 'accel-pptpd/ctrl')
-rw-r--r-- | accel-pptpd/ctrl/l2tp/l2tp.c | 31 | ||||
-rw-r--r-- | accel-pptpd/ctrl/pptp/pptp.c | 41 |
2 files changed, 46 insertions, 26 deletions
diff --git a/accel-pptpd/ctrl/l2tp/l2tp.c b/accel-pptpd/ctrl/l2tp/l2tp.c index 4c21af4..ca56051 100644 --- a/accel-pptpd/ctrl/l2tp/l2tp.c +++ b/accel-pptpd/ctrl/l2tp/l2tp.c @@ -48,7 +48,7 @@ int conf_timeout = 60; int conf_rtimeout = 5; int conf_retransmit = 5; int conf_hello_interval = 60; -const char *conf_host_name = "accel-pptp"; +char *conf_host_name = NULL; static unsigned int stat_active; static unsigned int stat_starting; @@ -504,7 +504,7 @@ static void l2tp_send_SCCRP(struct l2tp_conn_t *conn) if (l2tp_packet_add_int16(pack, Protocol_Version, L2TP_V2_PROTOCOL_VERSION, 1)) goto out_err; - if (l2tp_packet_add_string(pack, Host_Name, conf_host_name, 1)) + if (conf_host_name && l2tp_packet_add_string(pack, Host_Name, conf_host_name, 1)) goto out_err; if (l2tp_packet_add_int32(pack, Framing_Capabilities, conn->framing_cap, 1)) goto out_err; @@ -1090,15 +1090,10 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, return CLI_CMD_OK; } -static void __init l2tp_init(void) +static void load_config(void) { char *opt; - l2tp_conn = malloc(L2TP_MAX_TID * sizeof(void *)); - memset(l2tp_conn, 0, L2TP_MAX_TID * sizeof(void *)); - - l2tp_conn_pool = mempool_create(sizeof(struct l2tp_conn_t)); - opt = conf_get_opt("l2tp", "verbose"); if (opt && atoi(opt) > 0) conf_verbose = 1; @@ -1119,12 +1114,28 @@ static void __init l2tp_init(void) if (opt && atoi(opt) > 0) conf_retransmit = atoi(opt); + if (conf_host_name) + _free(conf_host_name); opt = conf_get_opt("l2tp", "host-name"); - if (opt && atoi(opt) > 0) - conf_host_name = opt; + if (opt) + conf_host_name = _strdup(opt); + else + conf_host_name = NULL; +} + +static void __init l2tp_init(void) +{ + l2tp_conn = malloc(L2TP_MAX_TID * sizeof(void *)); + memset(l2tp_conn, 0, L2TP_MAX_TID * sizeof(void *)); + + l2tp_conn_pool = mempool_create(sizeof(struct l2tp_conn_t)); + + load_config(); start_udp_server(); cli_register_simple_cmd2(&show_stat_exec, NULL, 2, "show", "stat"); + + triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); } diff --git a/accel-pptpd/ctrl/pptp/pptp.c b/accel-pptpd/ctrl/pptp/pptp.c index 0b92474..687aecb 100644 --- a/accel-pptpd/ctrl/pptp/pptp.c +++ b/accel-pptpd/ctrl/pptp/pptp.c @@ -700,6 +700,27 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, return CLI_CMD_OK; } +static void load_config(void) +{ + char *opt; + + opt = conf_get_opt("pptp", "timeout"); + if (opt && atoi(opt) > 0) + conf_timeout = atoi(opt); + + opt = conf_get_opt("pptp", "echo-interval"); + if (opt && atoi(opt) >= 0) + conf_echo_interval = atoi(opt); + + opt = conf_get_opt("pptp", "echo-failure"); + if (opt && atoi(opt) > 0) + conf_echo_failure = atoi(opt); + + opt = conf_get_opt("pptp", "verbose"); + if (opt && atoi(opt) > 0) + conf_verbose = 1; +} + static void __init pptp_init(void) { struct sockaddr_in addr; @@ -738,29 +759,17 @@ static void __init pptp_init(void) return; } - opt = conf_get_opt("pptp", "timeout"); - if (opt && atoi(opt) > 0) - conf_timeout = atoi(opt); - - opt = conf_get_opt("pptp", "echo-interval"); - if (opt && atoi(opt) >= 0) - conf_echo_interval = atoi(opt); - - opt = conf_get_opt("pptp", "echo-failure"); - if (opt && atoi(opt) > 0) - conf_echo_failure = atoi(opt); - - opt = conf_get_opt("pptp", "verbose"); - if (opt && atoi(opt) > 0) - conf_verbose = 1; - conn_pool = mempool_create(sizeof(struct pptp_conn_t)); + load_config(); + triton_context_register(&serv.ctx, NULL); triton_md_register_handler(&serv.ctx, &serv.hnd); triton_md_enable_handler(&serv.hnd, MD_MODE_READ); triton_context_wakeup(&serv.ctx); cli_register_simple_cmd2(show_stat_exec, NULL, 2, "show", "stat"); + + triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); } |