From 7a365e2112baa87e97545dc4ad5cd0a89a60da5c Mon Sep 17 00:00:00 2001 From: Suvendhu Hansa Date: Mon, 15 Sep 2025 11:17:59 +0530 Subject: [PATCH] Remove cwmp_stop from main process --- src/config.c | 5 +---- src/cwmp.c | 3 --- src/http.c | 3 +++ src/notifications.c | 2 -- src/session.c | 49 ++++++++++++++++++--------------------------- 5 files changed, 23 insertions(+), 39 deletions(-) diff --git a/src/config.c b/src/config.c index 65c15bc..dafae1f 100755 --- a/src/config.c +++ b/src/config.c @@ -88,13 +88,10 @@ void cwmp_config_load() global_conf_init(); - if (cwmp_stop == true) - return; - cwmp_ctx.net.ipv6_status = is_ipv6_enabled(); error = icwmp_check_http_connection(); - while (error != CWMP_OK && cwmp_stop != true) { + while (error != CWMP_OK) { CWMP_LOG(DEBUG, "Init: failed to check http connection"); sleep(UCI_OPTION_READ_INTERVAL); global_conf_init(); diff --git a/src/cwmp.c b/src/cwmp.c index f089cba..b25a693 100644 --- a/src/cwmp.c +++ b/src/cwmp.c @@ -214,9 +214,6 @@ static int cwmp_init(void) cwmp_ctx.prev_heartbeat_interval = cwmp_ctx.conf.heartbeat_interval; cwmp_ctx.prev_heartbeat_time = cwmp_ctx.conf.heart_time; - if (cwmp_stop == true) - return CWMP_GEN_ERR; - set_cpe_port_conf(cwmp_ctx.conf.connection_request_port); cwmp_get_deviceid(); diff --git a/src/http.c b/src/http.c index 3504fb0..15b52a0 100644 --- a/src/http.c +++ b/src/http.c @@ -745,6 +745,9 @@ void icwmp_http_server_listen(void) CWMP_LOG(ERROR, "Could not accept connections for Connection Request!"); shutdown(cwmp_ctx.cr_socket_desc, SHUT_RDWR); icwmp_http_server_init(); + if (cwmp_stop) + return; + listen(cwmp_ctx.cr_socket_desc, 5); cr_request = 0; restrict_start_time = 0; diff --git a/src/notifications.c b/src/notifications.c index 11c3eb6..105519f 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -799,8 +799,6 @@ void sotfware_version_value_change(struct transfer_complete *p) void periodic_check_notifiy(struct uloop_timeout *timeout __attribute__((unused))) { int is_notify = 0; - if (cwmp_stop) - return; /* If ConnectionRequestURL is empty then reschedule the timer after 5 second for * maximum of 3 times to check the upstream connection is stable, before enqueing diff --git a/src/session.c b/src/session.c index 1d009ef..88cfd06 100644 --- a/src/session.c +++ b/src/session.c @@ -127,7 +127,7 @@ int cwmp_schedule_rpc() struct list_head *ilist; struct rpc *rpc_acs; - if (icwmp_http_client_init() || cwmp_stop) { + if (icwmp_http_client_init()) { CWMP_LOG(INFO, "Initializing http client failed"); goto retry; } @@ -140,22 +140,22 @@ int cwmp_schedule_rpc() cwmp_session_rpc_destructor(rpc_acs); continue; } - if (!rpc_acs->type || cwmp_stop) + if (!rpc_acs->type) goto retry; CWMP_LOG(INFO, "Preparing the %s RPC message to send to the ACS", rpc_acs_methods[rpc_acs->type].name); - if (rpc_acs_methods[rpc_acs->type].prepare_message(rpc_acs) || cwmp_stop) + if (rpc_acs_methods[rpc_acs->type].prepare_message(rpc_acs)) goto retry; - if (xml_set_cwmp_id() || cwmp_stop) + if (xml_set_cwmp_id()) goto retry; CWMP_LOG(INFO, "Send the %s RPC message to the ACS", rpc_acs_methods[rpc_acs->type].name); - if (xml_send_message(rpc_acs) || cwmp_stop) + if (xml_send_message(rpc_acs)) goto retry; CWMP_LOG(INFO, "Get the %sResponse message from the ACS", rpc_acs_methods[rpc_acs->type].name); - if (rpc_acs_methods[rpc_acs->type].parse_response || cwmp_stop) + if (rpc_acs_methods[rpc_acs->type].parse_response) if (rpc_acs_methods[rpc_acs->type].parse_response(rpc_acs)) goto retry; @@ -165,37 +165,37 @@ int cwmp_schedule_rpc() cwmp_session_rpc_destructor(rpc_acs); MXML_DELETE(cwmp_ctx.session->tree_in); MXML_DELETE(cwmp_ctx.session->tree_out); - if (cwmp_ctx.session->hold_request || cwmp_stop) + if (cwmp_ctx.session->hold_request) break; } CWMP_LOG(INFO, "Send empty message to the ACS"); - if (xml_send_message(NULL) || cwmp_stop) + if (xml_send_message(NULL)) goto retry; - if (!cwmp_ctx.session->tree_in || cwmp_stop) + if (!cwmp_ctx.session->tree_in) goto next; CWMP_LOG(INFO, "Receive request from the ACS"); - if (xml_handle_message() || cwmp_stop) + if (xml_handle_message()) goto retry; while (cwmp_ctx.session->rpc_cpe) { CWMP_LOG(INFO, "Preparing the %s%s message", rpc_cpe_methods[cwmp_ctx.session->rpc_cpe->type].name, (cwmp_ctx.session->rpc_cpe->type != RPC_CPE_FAULT) ? "Response" : ""); - if (cwmp_rpc_cpe_handle_message(cwmp_ctx.session->rpc_cpe) || cwmp_stop) + if (cwmp_rpc_cpe_handle_message(cwmp_ctx.session->rpc_cpe)) goto retry; MXML_DELETE(cwmp_ctx.session->tree_in); CWMP_LOG(INFO, "Send the %s%s message to the ACS", rpc_cpe_methods[cwmp_ctx.session->rpc_cpe->type].name, (cwmp_ctx.session->rpc_cpe->type != RPC_CPE_FAULT) ? "Response" : ""); - if (xml_send_message(cwmp_ctx.session->rpc_cpe) || cwmp_stop) + if (xml_send_message(cwmp_ctx.session->rpc_cpe)) goto retry; MXML_DELETE(cwmp_ctx.session->tree_out); FREE(cwmp_ctx.session->rpc_cpe); - if (!cwmp_ctx.session->tree_in || cwmp_stop) + if (!cwmp_ctx.session->tree_in) break; CWMP_LOG(INFO, "Receive request from the ACS"); - if (xml_handle_message() || cwmp_stop) + if (xml_handle_message()) goto retry; } @@ -368,14 +368,12 @@ void start_cwmp_session(void) } if (is_ipv6_status_changed()) { - if (icwmp_check_http_connection() != CWMP_OK || cwmp_stop) { + if (icwmp_check_http_connection() != CWMP_OK) { CWMP_LOG(INFO, "Failed to check http connection"); - if (!cwmp_stop) { - /* clear inform and getrpc method from rpc list. - * These will be added in next session init */ - remove_inform_getrpc(); - schedule_session_retry(); - } + /* clear inform and getrpc method from rpc list. + * These will be added in next session init */ + remove_inform_getrpc(); + schedule_session_retry(); return; } } @@ -424,15 +422,6 @@ void start_cwmp_session(void) */ CWMP_LOG(INFO, "End session"); - if (cwmp_stop) { - cwmp_remove_all_session_events(); - run_session_end_func(); - rpc_exit(); - icwmp_cleanmem(); - - return; - } - if (cwmp_ctx.session->error == CWMP_RETRY_SESSION && (!list_empty(&(cwmp_ctx.session->events)) || (list_empty(&(cwmp_ctx.session->events)) && cwmp_ctx.cwmp_cr_event == 0))) { //CWMP Retry session // clear inform and getrpc method from rpc list. These will be added in next session init remove_inform_getrpc();