Revert "Do not commit in get operation"

This commit is contained in:
Vivek Dutta 2026-01-06 18:29:06 +05:30 committed by IOPSYS Dev
parent d76877c20b
commit 8201f79d12
No known key found for this signature in database
7 changed files with 7 additions and 84 deletions

View file

@ -294,8 +294,6 @@ static int bbfdm_handler_async(struct ubus_context *ctx, struct ubus_object *obj
context->ubus_ctx = ctx;
context->raw_format = raw_format;
INIT_LIST_HEAD(&context->uci_modified);
memset(&context->tmp_bb, 0, sizeof(struct blob_buf));
blob_buf_init(&context->tmp_bb, 0);

View file

@ -109,21 +109,6 @@ struct blob_attr *get_results_array(struct blob_attr *msg)
return tb[0];
}
struct blob_attr *get_modified_uci_array(struct blob_attr *msg)
{
struct blob_attr *tb[1] = {0};
const struct blobmsg_policy p[1] = {
{ "modified_uci", BLOBMSG_TYPE_ARRAY }
};
if (msg == NULL)
return NULL;
blobmsg_parse(p, 1, tb, blobmsg_data(msg), blobmsg_len(msg));
return tb[0];
}
bool str_match(const char *string, const char *pattern, size_t nmatch, regmatch_t pmatch[])
{
regex_t re;

View file

@ -39,7 +39,6 @@ unsigned int get_proto_type(const char *proto);
void fill_optional_input(struct blob_attr *msg, unsigned int *proto, bool *raw_format);
struct blob_attr *get_results_array(struct blob_attr *msg);
struct blob_attr *get_modified_uci_array(struct blob_attr *msg);
bool str_match(const char *string, const char *pattern, size_t nmatch, regmatch_t pmatch[]);
bool proto_match(unsigned int dm_type, const enum bbfdmd_type_enum type);

View file

@ -30,17 +30,6 @@ static void prepare_and_send_response(struct async_request_context *ctx)
blobmsg_close_array(&ctx->tmp_bb, ctx->array);
struct list_uci_modified *list_node = NULL, *tmp = NULL;
void *array = blobmsg_open_array(&ctx->tmp_bb, "modified_uci");
list_for_each_entry_safe(list_node, tmp, &ctx->uci_modified, list) {
blobmsg_add_string(&ctx->tmp_bb, "", list_node->file_path);
list_del(&list_node->list);
BBFDM_FREE(list_node);
}
blobmsg_close_array(&ctx->tmp_bb, array);
if (strcmp(ctx->ubus_method, "get") == 0 && ctx->raw_format == false) { // Pretty Format
struct blob_buf bb_pretty = {0};
@ -76,41 +65,11 @@ static void append_response_data(struct ubus_request_tracker *tracker, struct bl
return;
struct blob_attr *results = get_results_array(msg);
if (results) {
blobmsg_for_each_attr(attr, results, remaining) {
blobmsg_add_blob(&tracker->ctx->tmp_bb, attr);
}
}
if (!results)
return;
struct blob_attr *modified_uci = get_modified_uci_array(msg);
if (modified_uci) {
bool exist = false;
struct list_uci_modified *list_node = NULL;
attr = NULL;
remaining = 0;
blobmsg_for_each_attr(attr, modified_uci, remaining) {
list_for_each_entry(list_node, &tracker->ctx->uci_modified, list) {
if (strcmp(list_node->file_path, blobmsg_get_string(attr)) == 0) {
exist = true;
break;
}
}
if (exist == true)
continue;
list_node = (struct list_uci_modified *)calloc(1, sizeof(struct list_uci_modified));
if (list_node == NULL) {
BBFDM_INFO("Failed to allocate memory in get response handler for changed uci");
continue;
}
INIT_LIST_HEAD(&list_node->list);
list_add_tail(&list_node->list, &tracker->ctx->uci_modified);
snprintf(list_node->file_path, sizeof(list_node->file_path), "%s", blobmsg_get_string(attr));
}
blobmsg_for_each_attr(attr, results, remaining) {
blobmsg_add_blob(&tracker->ctx->tmp_bb, attr);
}
}

View file

@ -20,7 +20,6 @@ enum {
};
struct async_request_context {
struct list_head uci_modified;
struct ubus_context *ubus_ctx;
struct ubus_request_data request_data;
struct blob_buf tmp_bb;
@ -41,11 +40,6 @@ struct ubus_request_tracker {
char request_name[128];
};
struct list_uci_modified {
struct list_head list;
char file_path[2048];
};
void run_async_call(struct async_request_context *ctx, service_entry_t *service, struct blob_attr *msg);
void send_response(struct async_request_context *ctx);

View file

@ -42,16 +42,6 @@ void bbfdm_get(bbfdm_data_t *data, int method)
blobmsg_close_array(&data->bbf_ctx.bb, array);
array = blobmsg_open_array(&data->bbf_ctx.bb, "modified_uci");
if (data->bbf_ctx.modified_uci_head != NULL) {
struct dm_modified_uci *m;
list_for_each_entry(m, data->bbf_ctx.modified_uci_head, list) {
bb_add_string(&data->bbf_ctx.bb, "", m->uci_file);
}
}
blobmsg_close_array(&data->bbf_ctx.bb, array);
if (!validate_msglen(data)) {
BBF_ERR("IPC failed for path(%s)", data->bbf_ctx.in_param);
}
@ -60,10 +50,8 @@ void bbfdm_get(bbfdm_data_t *data, int method)
ubus_send_reply(data->ctx, data->req, data->bbf_ctx.bb.head);
}
// Apply all bbfdm dmmap changes
if (data->bbf_ctx.dm_type == BBFDM_BOTH) {
dmuci_commit_bbfdm();
}
// Apply all bbfdm changes
dmuci_commit_bbfdm();
bbf_cleanup(&data->bbf_ctx);
}

View file

@ -105,7 +105,7 @@ static void add_external_action_list(struct list_head *action_list, struct list_
bool arg_exist = false;
list_for_each_entry(act_node, action_list, list) {
if (strcmp(act_node->action, DEFAULT_HANDLER_ACT) == 0) {
if (strcmp(app_node->action, DEFAULT_HANDLER_ACT) == 0) {
node_exist = true;
for (int i = 0; i < act_node->idx; i++) {
if (strcmp(act_node->arg[i], config) == 0) {