mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-12 12:08:44 +01:00
uci_ctx and ubus_ctx should be initiated in the dm_ctx_init and not in the global init.
There is a risk that some modif in the running session are not loaded in the uci_ctx and ubus_ctx
This commit is contained in:
parent
dd53a4cd75
commit
3793b7de2e
5 changed files with 53 additions and 25 deletions
4
config.c
4
config.c
|
|
@ -731,11 +731,14 @@ int save_acs_bkp_config(struct cwmp *cwmp)
|
|||
}
|
||||
|
||||
int cwmp_get_deviceid(struct cwmp *cwmp) {
|
||||
struct dmctx dmctx = {0};
|
||||
dm_ctx_init(&dmctx);
|
||||
cwmp->deviceid.manufacturer = strdup(get_deviceid_manufacturer()); //TODO free
|
||||
cwmp->deviceid.serialnumber = strdup(get_deviceid_serialnumber());
|
||||
cwmp->deviceid.productclass = strdup(get_deviceid_productclass());
|
||||
cwmp->deviceid.oui = strdup(get_deviceid_manufactureroui());
|
||||
cwmp->deviceid.softwareversion = strdup(get_softwareversion());
|
||||
dm_ctx_clean(&dmctx);
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
|
|
@ -775,7 +778,6 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
|
|||
dm_global_init();
|
||||
cwmp_get_deviceid(cwmp);
|
||||
dm_entry_load_enabled_notify();
|
||||
dm_global_clean();
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
1
cwmp.c
1
cwmp.c
|
|
@ -147,7 +147,6 @@ void cwmp_schedule_session (struct cwmp *cwmp)
|
|||
error = cwmp_schedule_rpc (cwmp,session);
|
||||
CWMP_LOG (INFO,"End session");
|
||||
run_session_end_func(session);
|
||||
dm_global_clean();
|
||||
if (session->error == CWMP_RETRY_SESSION)
|
||||
{
|
||||
error = cwmp_move_session_to_session_queue (cwmp, session);
|
||||
|
|
|
|||
62
dm/dmentry.c
62
dm/dmentry.c
|
|
@ -21,31 +21,30 @@ LIST_HEAD(head_package_change);
|
|||
int dm_global_init(void)
|
||||
{
|
||||
dm_entry_set_prefix_methods_enable();
|
||||
memset(&dmubus_ctx, 0, sizeof(struct dmubus_ctx));
|
||||
INIT_LIST_HEAD(&dmubus_ctx.obj_head);
|
||||
uci_ctx = uci_alloc_context();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dm_global_clean(void)
|
||||
{
|
||||
if (uci_ctx) uci_free_context(uci_ctx);
|
||||
uci_ctx= NULL;
|
||||
dmubus_ctx_free(&dmubus_ctx);
|
||||
dmcleanmem();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dm_ctx_init(struct dmctx *ctx)
|
||||
static int dm_ctx_init_custom(struct dmctx *ctx, int custom)
|
||||
{
|
||||
if (custom == CTX_INIT_ALL) {
|
||||
memset(&dmubus_ctx, 0, sizeof(struct dmubus_ctx));
|
||||
INIT_LIST_HEAD(&dmubus_ctx.obj_head);
|
||||
uci_ctx = uci_alloc_context();
|
||||
}
|
||||
INIT_LIST_HEAD(&ctx->list_parameter);
|
||||
INIT_LIST_HEAD(&ctx->set_list_tmp);
|
||||
INIT_LIST_HEAD(&ctx->list_fault_param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dm_ctx_clean(struct dmctx *ctx)
|
||||
static int dm_ctx_clean_custom(struct dmctx *ctx, int custom)
|
||||
{
|
||||
if (custom == CTX_INIT_ALL) {
|
||||
if (uci_ctx) uci_free_context(uci_ctx);
|
||||
uci_ctx = NULL;
|
||||
dmubus_ctx_free(&dmubus_ctx);
|
||||
dmcleanmem();
|
||||
}
|
||||
free_all_list_parameter(ctx);
|
||||
free_all_set_list_tmp(ctx);
|
||||
free_all_list_fault_param(ctx);
|
||||
|
|
@ -53,6 +52,31 @@ int dm_ctx_clean(struct dmctx *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int dm_ctx_init(struct dmctx *ctx)
|
||||
{
|
||||
dm_ctx_init_custom(ctx, CTX_INIT_ALL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dm_ctx_clean(struct dmctx *ctx)
|
||||
{
|
||||
dm_ctx_clean_custom(ctx, CTX_INIT_ALL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dm_ctx_init_sub(struct dmctx *ctx)
|
||||
{
|
||||
dm_ctx_init_custom(ctx, CTX_INIT_SUB);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dm_ctx_clean_sub(struct dmctx *ctx)
|
||||
{
|
||||
dm_ctx_clean_custom(ctx, CTX_INIT_SUB);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, char *arg2)
|
||||
{
|
||||
int fault = 0;
|
||||
|
|
@ -190,7 +214,7 @@ int adm_entry_get_linker_param(char *param, char *linker, char **value)
|
|||
{
|
||||
struct dmctx dmctx = {0};
|
||||
|
||||
dm_ctx_init(&dmctx);
|
||||
dm_ctx_init_sub(&dmctx);
|
||||
dmctx.in_param = param ? param : "";
|
||||
dmctx.linker = linker;
|
||||
|
||||
|
|
@ -204,7 +228,7 @@ int adm_entry_get_linker_param(char *param, char *linker, char **value)
|
|||
dm_entry_get_linker(&dmctx);
|
||||
*value = dmctx.linker_param;
|
||||
|
||||
dm_ctx_clean(&dmctx);
|
||||
dm_ctx_clean_sub(&dmctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -217,14 +241,14 @@ int adm_entry_get_linker_value(char *param, char **value)
|
|||
return 0;
|
||||
}
|
||||
|
||||
dm_ctx_init(&dmctx);
|
||||
dm_ctx_init_sub(&dmctx);
|
||||
dmctx.in_param = param;
|
||||
dmctx.tree = false;
|
||||
|
||||
dm_entry_get_linker_value(&dmctx);
|
||||
*value = dmctx.linker;
|
||||
|
||||
dm_ctx_clean(&dmctx);
|
||||
dm_ctx_clean_sub(&dmctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -372,12 +396,10 @@ void dm_entry_cli(int argc, char** argv)
|
|||
goto invalid_arguments;
|
||||
}
|
||||
dm_ctx_clean(&cli_dmctx);
|
||||
dm_global_clean();
|
||||
return;
|
||||
|
||||
invalid_arguments:
|
||||
dm_ctx_clean(&cli_dmctx);
|
||||
dm_global_clean();
|
||||
fprintf(stdout, "Invalid arguments!\n");;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,15 +3,22 @@
|
|||
|
||||
#include "dmcwmp.h"
|
||||
extern struct list_head head_package_change;
|
||||
|
||||
enum ctx_init_enum {
|
||||
CTX_INIT_ALL,
|
||||
CTX_INIT_SUB
|
||||
};
|
||||
|
||||
int dm_global_init(void);
|
||||
int dm_ctx_init(struct dmctx *ctx);
|
||||
int dm_ctx_init_sub(struct dmctx *ctx);
|
||||
int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, char *arg2);
|
||||
int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1, char *arg2);
|
||||
int dm_entry_load_enabled_notify();
|
||||
int adm_entry_get_linker_param(char *param, char *linker, char **value);
|
||||
int adm_entry_get_linker_value(char *param, char **value);
|
||||
int dm_ctx_clean(struct dmctx *ctx);
|
||||
int dm_global_clean(void);
|
||||
int dm_ctx_clean_sub(struct dmctx *ctx);
|
||||
void dm_entry_cli(int argc, char** argv);
|
||||
void wepkey_cli(int argc, char** argv);
|
||||
#endif
|
||||
|
|
|
|||
2
ubus.c
2
ubus.c
|
|
@ -52,7 +52,6 @@ cwmp_handle_notify(struct ubus_context *ctx, struct ubus_object *obj,
|
|||
pthread_mutex_lock(&(cwmp_main.mutex_session_queue));
|
||||
dm_global_init();
|
||||
cwmp_add_notification();
|
||||
dm_global_clean();
|
||||
pthread_mutex_unlock(&(cwmp_main.mutex_session_queue));
|
||||
blobmsg_add_u32(&b, "status", 0);
|
||||
}
|
||||
|
|
@ -108,7 +107,6 @@ cwmp_handle_command(struct ubus_context *ctx, struct ubus_object *obj,
|
|||
pthread_mutex_lock (&(cwmp_main.mutex_session_queue));
|
||||
dm_global_init();
|
||||
cwmp_apply_acs_changes();
|
||||
dm_global_clean();
|
||||
pthread_mutex_unlock (&(cwmp_main.mutex_session_queue));
|
||||
blobmsg_add_u32(&b, "status", 0);
|
||||
if (asprintf(&info, "freecwmp config reloaded") == -1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue