From 5401894b4e447aa72d0acf82bd938a04a0330dc5 Mon Sep 17 00:00:00 2001 From: Omar Kallel Date: Tue, 23 Nov 2021 18:07:14 +0100 Subject: [PATCH] Get dhcp url from /etc/config/cwmp --- config.c | 2 +- cwmp.c | 1 - http.c | 5 ++++- ubus.c | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config.c b/config.c index aa67096..7d1bf10 100755 --- a/config.c +++ b/config.c @@ -104,7 +104,7 @@ int get_global_config(struct config *conf) error = uci_get_value(UCI_DHCP_DISCOVERY_PATH, &value); error2 = uci_get_value(UCI_ACS_URL_PATH, &value2); - error3 = uci_get_state_value(UCI_DHCP_ACS_URL, &value3); + error3 = uci_get_value(UCI_DHCP_ACS_URL, &value3); if ((((error == CWMP_OK) && (value != NULL) && (strcmp(value, "enable") == 0)) || ((error2 == CWMP_OK) && ((value2 == NULL) || (value2[0] == 0)))) && ((error3 == CWMP_OK) && (value3 != NULL) && (value3[0] != 0))) { FREE(conf->acsurl); diff --git a/cwmp.c b/cwmp.c index 93e4ff9..9b29a17 100644 --- a/cwmp.c +++ b/cwmp.c @@ -665,7 +665,6 @@ static void *thread_cwmp_signal_handler_thread(void *arg) CWMP_LOG(INFO, "Catch of Signal(%d)", signal_num); if (signal_num == SIGINT || signal_num == SIGTERM) { - //copy_file(CWMP_BKP_FILE, "/etc/icwmpd/.icwmpd_backup_session.xml"); signal_exit = true; if (!ubus_exit) diff --git a/http.c b/http.c index 4b0fe4e..fc30c22 100644 --- a/http.c +++ b/http.c @@ -119,12 +119,15 @@ static size_t http_get_response(void *buffer, size_t size, size_t rxed, char **m { char *c; + if (*msg_in == NULL) + return 0; + if (cwmp_asprintf(&c, "%s%.*s", *msg_in, (int)(size * rxed), (char *)buffer) == -1) { FREE(*msg_in); return -1; } - free(*msg_in); + FREE(*msg_in); *msg_in = c; return size * rxed; diff --git a/ubus.c b/ubus.c index af06e5b..ff8455d 100755 --- a/ubus.c +++ b/ubus.c @@ -111,13 +111,13 @@ static int cwmp_handle_command(struct ubus_context *ctx, struct ubus_object *obj pthread_cond_signal(&threshold_apply_schedule_download); pthread_cond_signal(&threshold_upload); + uloop_end(); + shutdown(cwmp_main.cr_socket_desc, SHUT_RDWR); if (!signal_exit) kill(getpid(), SIGTERM); - uloop_end(); - if (snprintf(info, sizeof(info), "icwmpd daemon stopped") == -1) return -1; } else {