mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Optimize uci reinit and config load
This commit is contained in:
parent
93920c80e5
commit
79322a0d95
5 changed files with 25 additions and 22 deletions
|
|
@ -603,7 +603,6 @@ void cwmp_config_load()
|
|||
{
|
||||
int ret;
|
||||
|
||||
cwmp_uci_reinit();
|
||||
ret = global_conf_init();
|
||||
while (ret != CWMP_OK && cwmp_stop != true) {
|
||||
CWMP_LOG(DEBUG, "Error reading uci ret = %d", ret);
|
||||
|
|
@ -626,6 +625,7 @@ int cwmp_get_deviceid()
|
|||
int cwmp_config_reload()
|
||||
{
|
||||
memset(&cwmp_main->env, 0, sizeof(struct env));
|
||||
cwmp_uci_reinit();
|
||||
int err = global_conf_init();
|
||||
if (err != CWMP_OK)
|
||||
return err;
|
||||
|
|
|
|||
38
src/cwmp.c
38
src/cwmp.c
|
|
@ -196,6 +196,22 @@ end:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void configure_var_state()
|
||||
{
|
||||
char *zone_name = NULL;
|
||||
|
||||
if (!file_exists(VARSTATE_CONFIG"/cwmp"))
|
||||
creat(VARSTATE_CONFIG"/cwmp", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
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_main->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);
|
||||
}
|
||||
|
||||
static int cwmp_init()
|
||||
{
|
||||
int error;
|
||||
|
|
@ -234,6 +250,7 @@ static int cwmp_init()
|
|||
if ((error = create_cwmp_notifications_package()))
|
||||
return error;
|
||||
|
||||
cwmp_uci_init();
|
||||
CWMP_LOG(DEBUG, "Loading icwmpd configuration");
|
||||
cwmp_config_load();
|
||||
|
||||
|
|
@ -253,6 +270,9 @@ static int cwmp_init()
|
|||
load_custom_notify_json();
|
||||
set_default_forced_active_parameters_notifications();
|
||||
init_list_param_notify();
|
||||
configure_var_state();
|
||||
cwmp_uci_exit();
|
||||
|
||||
create_cwmp_session_structure();
|
||||
get_nonce_key();
|
||||
memset(&intf_reset_list, 0, sizeof(struct list_head));
|
||||
|
|
@ -338,23 +358,6 @@ void cwmp_exit()
|
|||
cwmp_free();
|
||||
}
|
||||
|
||||
static void configure_var_state()
|
||||
{
|
||||
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_main->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)
|
||||
{
|
||||
int error;
|
||||
|
|
@ -379,7 +382,6 @@ int main(int argc, char **argv)
|
|||
if ((error = cwmp_root_cause_events()))
|
||||
return error;
|
||||
|
||||
configure_var_state();
|
||||
icwmp_http_server_init();
|
||||
|
||||
uloop_init();
|
||||
|
|
|
|||
|
|
@ -344,7 +344,6 @@ void create_list_param_obj_notify()
|
|||
struct uci_element *e = NULL;
|
||||
int i;
|
||||
|
||||
cwmp_uci_reinit();
|
||||
for (i = 0; i < 7; i++) {
|
||||
int option_type;
|
||||
option_type = cwmp_uci_get_option_value_list("cwmp_notifications", "@notifications[0]", notifications[i], UCI_ETCICWMPD_CONFIG, &list_notif);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ int cwmp_session_init()
|
|||
cwmp_main->cwmp_cr_event = 0;
|
||||
|
||||
cwmp_uci_init();
|
||||
|
||||
/*
|
||||
* Set Required methods as initial value of
|
||||
*/
|
||||
|
|
@ -259,7 +260,6 @@ static void set_cwmp_session_status_state(int status)
|
|||
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", "sess_status", "sess_status", UCI_VARSTATE_CONFIG);
|
||||
|
||||
switch (status) {
|
||||
|
|
@ -329,10 +329,10 @@ void start_cwmp_session()
|
|||
uloop_timeout_cancel(&check_notify_timer);
|
||||
if (cwmp_session_init() != CWMP_OK) {
|
||||
CWMP_LOG(ERROR, "Not able to init a CWMP session");
|
||||
cwmp_config_load();
|
||||
t = cwmp_get_retry_interval(0);
|
||||
CWMP_LOG(INFO, "Retry session, retry count = %d, retry in %ds", cwmp_main->retry_count_session, t);
|
||||
set_cwmp_session_status(SESSION_FAILURE, t);
|
||||
cwmp_config_load();
|
||||
trigger_periodic_notify_check();
|
||||
return;
|
||||
}
|
||||
|
|
@ -625,6 +625,7 @@ int run_session_end_func(void)
|
|||
|
||||
if (end_session_flag & END_SESSION_INIT_NOTIFY) {
|
||||
CWMP_LOG(INFO, "SetParameterAttributes end session: reinit list notify");
|
||||
cwmp_uci_reinit();
|
||||
reinit_list_param_notify();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ static int reload_cmd(struct blob_buf *b)
|
|||
blobmsg_add_u32(b, "status", 0);
|
||||
blobmsg_add_string(b, "info", "icwmpd config reloaded");
|
||||
}
|
||||
cwmp_uci_exit();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue