diff --git a/src/common.c b/src/common.c index 5939b31..82bf2de 100755 --- a/src/common.c +++ b/src/common.c @@ -574,8 +574,10 @@ void icwmp_free(void *m) return; struct cwmp_mem *rm; rm = container_of(m, struct cwmp_mem, mem); - list_del(&rm->list); - free(rm); + if (rm != NULL) { + list_del(&rm->list); + free(rm); + } } void icwmp_cleanmem() @@ -583,8 +585,10 @@ void icwmp_cleanmem() struct cwmp_mem *mem; while (cwmp_memory_list.next != &cwmp_memory_list) { mem = list_entry(cwmp_memory_list.next, struct cwmp_mem, list); - list_del(&mem->list); - free(mem); + if (mem != NULL) { + list_del(&mem->list); + free(mem); + } } } diff --git a/src/config.c b/src/config.c index 7c6bc48..5318df1 100755 --- a/src/config.c +++ b/src/config.c @@ -22,6 +22,7 @@ #include "ssl_utils.h" #include "datamodel_interface.h" #include "heartbeat.h" +#include "cwmp_http.h" pthread_mutex_t mutex_config_load = PTHREAD_MUTEX_INITIALIZER; @@ -628,14 +629,33 @@ end: void cwmp_config_load() { - int ret; + int ret = CWMP_GEN_ERR; + int error = CWMP_GEN_ERR; ret = global_conf_init(); - while (ret != CWMP_OK && cwmp_stop != true) { - CWMP_LOG(DEBUG, "Error reading uci ret = %d", ret); + + if (cwmp_stop == true) + return; + + if (ret == CWMP_OK) { + cwmp_main->net.ipv6_status = is_ipv6_enabled(); + error = icwmp_check_http_connection(); + } + + while (error != CWMP_OK && cwmp_stop != true) { + if (ret != CWMP_OK) { + CWMP_LOG(DEBUG, "Error reading uci ret = %d", ret); + } else { + CWMP_LOG(DEBUG, "Init: failed to check http connection"); + } + sleep(UCI_OPTION_READ_INTERVAL); cwmp_uci_reinit(); ret = global_conf_init(); + if (ret == CWMP_OK) { + cwmp_main->net.ipv6_status = is_ipv6_enabled(); + error = icwmp_check_http_connection(); + } } } diff --git a/src/cwmp.c b/src/cwmp.c index 493ae02..b0b489b 100644 --- a/src/cwmp.c +++ b/src/cwmp.c @@ -283,13 +283,6 @@ static int cwmp_init(void) INIT_LIST_HEAD(&du_uuid_list); cwmp_main->start_time = time(NULL); - cwmp_main->net.ipv6_status = is_ipv6_enabled(); - error = icwmp_check_http_connection(); - if (error != CWMP_OK) { - CWMP_LOG(DEBUG, "Init: failed to check http connection"); - return error; - } - cwmp_uci_exit(); return CWMP_OK; diff --git a/src/session.c b/src/session.c index 4033a08..4e005d9 100644 --- a/src/session.c +++ b/src/session.c @@ -334,8 +334,11 @@ void start_cwmp_session() return; } - if (cwmp_main->session->session_status.last_status == SESSION_FAILURE) + if (cwmp_main->session->session_status.last_status == SESSION_FAILURE) { + cwmp_uci_reinit(); cwmp_config_load(); + cwmp_uci_exit(); + } if (is_ipv6_status_changed()) { if (icwmp_check_http_connection() != CWMP_OK || cwmp_stop) {