mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Fix delay reloading services
This commit is contained in:
parent
c9eac993f0
commit
bf33885bf7
2 changed files with 25 additions and 15 deletions
28
cwmp.c
28
cwmp.c
|
|
@ -199,6 +199,11 @@ end:
|
|||
|
||||
int run_session_end_func(void)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_RESTART_SERVICES) {
|
||||
CWMP_LOG(INFO, "Restart modified services");
|
||||
icwmp_restart_services();
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_RELOAD) {
|
||||
CWMP_LOG(INFO, "Config reload: end session request");
|
||||
cwmp_uci_reinit();
|
||||
|
|
@ -250,11 +255,6 @@ int run_session_end_func(void)
|
|||
cwmp_upload_diagnostics();
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_RESTART_SERVICES) {
|
||||
CWMP_LOG(INFO, "Restart modified services");
|
||||
icwmp_restart_services();
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_REBOOT) {
|
||||
CWMP_LOG(INFO, "Executing Reboot: end session request");
|
||||
cwmp_reboot(commandKey);
|
||||
|
|
@ -612,6 +612,23 @@ static void *thread_cwmp_signal_handler_thread(void *arg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void configure_var_state(struct cwmp *cwmp)
|
||||
{
|
||||
char *zone_name = NULL;
|
||||
|
||||
if (!file_exists(VARSTATE_CONFIG"/cwmp"))
|
||||
creat(VARSTATE_CONFIG"/cwmp", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
cwmp_uci_reinit();
|
||||
cwmp_uci_add_section_with_specific_name("cwmp", "acs", "acs", UCI_VARSTATE_CONFIG);
|
||||
cwmp_uci_add_section_with_specific_name("cwmp", "cpe", "cpe", UCI_VARSTATE_CONFIG);
|
||||
|
||||
get_firewall_zone_name_by_wan_iface(cwmp->conf.default_wan_iface, &zone_name);
|
||||
cwmp_uci_set_varstate_value("cwmp", "acs", "zonename", zone_name ? zone_name : "wan");
|
||||
|
||||
cwmp_commit_package("cwmp", UCI_VARSTATE_CONFIG);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
|
|
@ -630,6 +647,7 @@ int main(int argc, char **argv)
|
|||
if ((error = cwmp_root_cause_events(cwmp)))
|
||||
return error;
|
||||
|
||||
configure_var_state(cwmp);
|
||||
http_server_init();
|
||||
|
||||
sigemptyset(&set);
|
||||
|
|
|
|||
12
http.c
12
http.c
|
|
@ -235,19 +235,11 @@ int http_send_message(struct cwmp *cwmp, char *msg_out, int msg_out_len, char **
|
|||
tmp = 0;
|
||||
else
|
||||
tmp = inet_pton(AF_INET6, ip, buf);
|
||||
cwmp_uci_add_section_with_specific_name("cwmp", "acs", "acs", UCI_VARSTATE_CONFIG);
|
||||
char *zone_name = NULL;
|
||||
get_firewall_zone_name_by_wan_iface(cwmp->conf.default_wan_iface, &zone_name);
|
||||
|
||||
cwmp_uci_set_varstate_value("cwmp", "acs", tmp ? "ip6" : "ip", ip_acs);
|
||||
char connection_requset_port_str[10];
|
||||
snprintf(connection_requset_port_str, sizeof(connection_requset_port_str), "%d", cwmp->conf.connection_request_port);
|
||||
cwmp_uci_set_varstate_value("cwmp", "acs", "port", connection_requset_port_str);
|
||||
cwmp_uci_set_varstate_value("cwmp", "acs", "zonename", zone_name ? zone_name : "wan");
|
||||
cwmp_commit_package("cwmp", UCI_VARSTATE_CONFIG);
|
||||
|
||||
/*
|
||||
* Restart firewall service
|
||||
*/
|
||||
// Trigger firewall to reload firewall.cwmp
|
||||
cwmp_ubus_call("uci", "commit", CWMP_UBUS_ARGS{ { "config", { .str_val = "firewall" }, UBUS_String } }, 1, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue