From 3ebdf2882c13b2d266aa5d0769f4b397db512e5a Mon Sep 17 00:00:00 2001 From: suvendhu <suvendhu.hansa@iopsys.eu> Date: Thu, 9 Dec 2021 17:12:45 +0530 Subject: [PATCH] optimization of du_list method --- src/swmod.c | 2 -- src/swmod_lxc.c | 6 ++++++ src/swmod_opkg.c | 17 ++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/swmod.c b/src/swmod.c index d1938af..c1f09b8 100644 --- a/src/swmod.c +++ b/src/swmod.c @@ -553,8 +553,6 @@ swmod_du_list(struct ubus_context *ctx, struct ubus_object *obj, void *a; unsigned int eid = get_eid_from_blob(msg); - synchronize_deployment_units_with_map_du_file(); - memset(&bb, 0, sizeof(struct blob_buf)); blob_buf_init(&bb, 0); diff --git a/src/swmod_lxc.c b/src/swmod_lxc.c index 4edc69f..42390db 100644 --- a/src/swmod_lxc.c +++ b/src/swmod_lxc.c @@ -675,6 +675,12 @@ int swmod_lxc_install_update_remove_package(const char *package_path, int cid, i sscanf(g_lxc_buff, "pkg_name=%63s pkg_version=%63s", package_name, package_version); } + + char root[512]; + snprintf(root, 512, "%s/%s/rootfs", lxcpath, ct->name); + PRINT_DEBUG("Reading from container[%s] path[%s]", ct->name, root); + populate_opkg_deployment_unit(cid + 2, root, ct->name); + FREE(g_lxc_buff); err = 0; } diff --git a/src/swmod_opkg.c b/src/swmod_opkg.c index 22d0b33..2432d6c 100644 --- a/src/swmod_opkg.c +++ b/src/swmod_opkg.c @@ -60,6 +60,11 @@ static int swmod_host_system_install_package(const char *package_path) pclose(log); } + if (err == 0) { + /* du unit installed, now update the du list */ + PRINT_DEBUG("Populate du for eid 1\n"); + populate_opkg_deployment_unit(1, NULL, NULL); + } return err; } @@ -88,6 +93,11 @@ static int swmod_host_system_update_package(const char *package_path) package_version[len - 3] = '\0'; } + if (err == 0) { + /* du unit updated, now update the du list */ + PRINT_DEBUG("Populate du for eid 1\n"); + populate_opkg_deployment_unit(1, NULL, NULL); + } return err; } @@ -110,6 +120,11 @@ int swmod_host_system_remove_package(const char *pname) pclose(log); } + if (err == 0) { + /* du unit removed, now update the du list */ + PRINT_DEBUG("Populate du for eid 1\n"); + populate_opkg_deployment_unit(1, NULL, NULL); + } return err; } @@ -220,7 +235,7 @@ int swmod_remove_package(const char *pname, int eid) bool is_opkg_service(const char *opkg_info, char *pkg_name) { /* Get Config from package_name.list */ - bool service = true; + bool service = false; char pkg_path[128] = {0}; snprintf(pkg_path, sizeof(pkg_path), "%s/%s.list", opkg_info, pkg_name); -- GitLab