Avoid uci commit when restart_service is false

This commit is contained in:
Vivek Kumar Dutta 2024-03-04 12:14:04 +00:00
parent 44db59203f
commit 3cdbb5432c
4 changed files with 5 additions and 17 deletions

View file

@ -372,7 +372,7 @@ int transaction_abort(bbfdm_data_t *data, int trans_id)
g_current_trans.trans_id = 0; g_current_trans.trans_id = 0;
g_current_trans.app[0] = '\0'; g_current_trans.app[0] = '\0';
if (bb) arr = blobmsg_open_array(bb, "reverted_configs"); if (bb) arr = blobmsg_open_array(bb, "updated_services");
bbf_entry_revert_changes(bb); bbf_entry_revert_changes(bb);
if (data && data->trans_id) { if (data && data->trans_id) {
// Call transaction for registered services only if transaction id is defined // Call transaction for registered services only if transaction id is defined

View file

@ -1250,7 +1250,7 @@ API to abort an on-going transaction, on calling this api, staged changes in uci
```console ```console
root@iopsys:~# ubus call bbfdm transaction '{"cmd":"abort", "optional":{"transaction_id":1695754826}}' root@iopsys:~# ubus call bbfdm transaction '{"cmd":"abort", "optional":{"transaction_id":1695754826}}'
{ {
"reverted_configs": [ "updated_services": [
"mapcontroller", "mapcontroller",
"wireless" "wireless"
], ],

View file

@ -446,8 +446,6 @@ void bbf_entry_restart_services(struct blob_buf *bb, bool restart_services)
if (restart_services) { if (restart_services) {
dmubus_call_set("uci", "commit", UBUS_ARGS{{"config", pc->package, String}}, 1); dmubus_call_set("uci", "commit", UBUS_ARGS{{"config", pc->package, String}}, 1);
} else {
dmuci_commit_package(pc->package);
} }
} }

View file

@ -119,10 +119,9 @@ bool load_service(DMOBJ *main_dm, struct list_head *srv_list, char *srv_name, ch
static void ubus_transaction_callback(struct ubus_request *req, int type __attribute__((unused)), struct blob_attr *msg) static void ubus_transaction_callback(struct ubus_request *req, int type __attribute__((unused)), struct blob_attr *msg)
{ {
struct blob_attr *tb[2] = {0}; struct blob_attr *tb[1] = {0};
const struct blobmsg_policy p[2] = { const struct blobmsg_policy p[1] = {
{ "updated_services", BLOBMSG_TYPE_ARRAY }, { "updated_services", BLOBMSG_TYPE_ARRAY },
{ "reverted_configs", BLOBMSG_TYPE_ARRAY }
}; };
if (msg == NULL || req == NULL) if (msg == NULL || req == NULL)
@ -132,7 +131,7 @@ static void ubus_transaction_callback(struct ubus_request *req, int type __attri
if (bb == NULL) if (bb == NULL)
return; return;
blobmsg_parse(p, 2, tb, blobmsg_data(msg), blobmsg_len(msg)); blobmsg_parse(p, 1, tb, blobmsg_data(msg), blobmsg_len(msg));
if (tb[0]) { if (tb[0]) {
struct blob_attr *service = NULL; struct blob_attr *service = NULL;
@ -142,15 +141,6 @@ static void ubus_transaction_callback(struct ubus_request *req, int type __attri
blobmsg_add_string(bb, NULL, blobmsg_get_string(service)); blobmsg_add_string(bb, NULL, blobmsg_get_string(service));
} }
} }
if (tb[1]) {
struct blob_attr *config = NULL;
size_t rem;
blobmsg_for_each_attr(config, tb[1], rem) {
blobmsg_add_string(bb, NULL, blobmsg_get_string(config));
}
}
} }
int handle_transaction_of_registered_service(struct ubus_context *ctx, struct blob_buf *trans_bb, struct list_head *srvlist, int handle_transaction_of_registered_service(struct ubus_context *ctx, struct blob_buf *trans_bb, struct list_head *srvlist,