diff options
-rw-r--r-- | src/afm-system-daemon.c | 17 | ||||
-rw-r--r-- | src/afm-user-daemon.c | 7 | ||||
-rw-r--r-- | src/wgtpkg-unit.c | 36 |
3 files changed, 21 insertions, 39 deletions
diff --git a/src/afm-system-daemon.c b/src/afm-system-daemon.c index 969bfaa..49749bc 100644 --- a/src/afm-system-daemon.c +++ b/src/afm-system-daemon.c @@ -29,6 +29,7 @@ #include "verbose.h" #include "utils-jbus.h" #include "utils-json.h" +#include "utils-systemd.h" #include "afm.h" #include "afm-db.h" #include "wgt-info.h" @@ -68,11 +69,21 @@ const char error_bad_request[] = "\"bad request\""; const char error_not_found[] = "\"not found\""; const char error_cant_start[] = "\"can't start\""; +static void do_reloads() +{ +#ifndef LEGACY_MODE_WITHOUT_SYSTEMD + /* enforce daemon reload */ + systemd_daemon_reload(0); + systemd_unit_restart_name(0, "sockets.target"); +#endif +} + static void on_install(struct sd_bus_message *smsg, struct json_object *req, void *unused) { const char *wgtfile; const char *root; int force; + int reload; struct wgt_info *ifo; struct json_object *resp; @@ -82,12 +93,14 @@ static void on_install(struct sd_bus_message *smsg, struct json_object *req, voi wgtfile = json_object_get_string(req); root = rootdir; force = 0; + reload = 1; break; case json_type_object: wgtfile = j_string_at(req, "wgt", NULL); if (wgtfile != NULL) { root = j_string_at(req, "root", rootdir); force = j_boolean_at(req, "force", 0); + reload = j_boolean_at(req, "reload", 1); break; } default: @@ -100,6 +113,10 @@ static void on_install(struct sd_bus_message *smsg, struct json_object *req, voi if (ifo == NULL) jbus_reply_error_s(smsg, "\"installation failed\""); else { + /* reload if needed */ + if (reload) + do_reloads(); + /* build the response */ resp = json_object_new_object(); if(!resp || !j_add_string(resp, "added", wgt_info_desc(ifo)->idaver)) diff --git a/src/afm-user-daemon.c b/src/afm-user-daemon.c index 481013f..a705381 100644 --- a/src/afm-user-daemon.c +++ b/src/afm-user-daemon.c @@ -488,14 +488,15 @@ static void on_uninstall(struct sd_bus_message *smsg, const char *msg, void *unu */ static void on_signal_changed(struct json_object *obj, void *unused) { +#ifdef LEGACY_MODE_WITHOUT_SYSTEMD + /* update the database */ + afm_db_update_applications(afdb); +#else /* enforce daemon reload */ systemd_daemon_reload(1); systemd_unit_restart_name(1, "sockets.target"); /* update the database */ -#ifdef LEGACY_MODE_WITHOUT_SYSTEMD - afm_db_update_applications(afdb); -#else afm_udb_update(afudb); #endif /* re-propagate now */ diff --git a/src/wgtpkg-unit.c b/src/wgtpkg-unit.c index e6e67bf..8607eb4 100644 --- a/src/wgtpkg-unit.c +++ b/src/wgtpkg-unit.c @@ -470,36 +470,6 @@ static int get_wants_target(char *path, size_t pathlen, const struct unitdesc *d return rc; } -static int do_send_reload(const struct generatedesc *desc) -{ - int i; - int reloadsys, reloadusr; - const struct unitdesc *u; - - reloadsys = reloadusr = 0; - for (i = 0 ; i < desc->nunits ; i++) { - u = &desc->units[i]; - if (u->wanted_by != NULL) { - switch (u->scope) { - case unitscope_user: - reloadusr = 1; - break; - case unitscope_system: - reloadsys = 1; - break; - default: - break; - } - } - } - - if (reloadusr) - reloadusr = systemd_daemon_reload(1); - if (reloadsys) - reloadsys = systemd_daemon_reload(0); - return 0; -} - static int do_uninstall_units(void *closure, const struct generatedesc *desc) { int rc, rc2; @@ -527,9 +497,6 @@ static int do_uninstall_units(void *closure, const struct generatedesc *desc) if (rc2 < 0 && rc == 0) rc = rc2; } - rc2 = do_send_reload(desc); - if (rc2 < 0 && rc == 0) - rc = rc2; return rc; } @@ -564,9 +531,6 @@ static int do_install_units(void *closure, const struct generatedesc *desc) if (rc < 0) goto error; } - rc = do_send_reload(desc); - if (rc < 0) - goto error; return 0; error: i = errno; |