chiark / gitweb /
dbus: add simplified way to start an arbitrary unit in a single method call
[elogind.git] / src / dbus-unit.c
index 5c474c0c1efc4daaa3b74934267ac56ac7fcca52..8e35377dc56370103424ac96cf05e10cbd52af06 100644 (file)
@@ -25,6 +25,8 @@
 #include "log.h"
 #include "dbus-unit.h"
 
+const char bus_unit_interface[] = BUS_UNIT_INTERFACE;
+
 int bus_unit_append_names(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         char *t;
         Iterator j;
@@ -258,6 +260,7 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
         Manager *m = u->meta.manager;
         DBusError error;
         JobType job_type = _JOB_TYPE_INVALID;
+        char *path = NULL;
 
         dbus_error_init(&error);
 
@@ -279,7 +282,6 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
                 JobMode mode;
                 Job *j;
                 int r;
-                char *path;
 
                 if (job_type == JOB_START && u->meta.only_by_dependency)
                         return bus_send_error_reply(m, message, NULL, -EPERM);
@@ -310,6 +312,8 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
                         goto oom;
         }
 
+        free(path);
+
         if (reply) {
                 if (!dbus_connection_send(m->api_bus, reply, NULL))
                         goto oom;
@@ -320,6 +324,8 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
         return DBUS_HANDLER_RESULT_HANDLED;
 
 oom:
+        free(path);
+
         if (reply)
                 dbus_message_unref(reply);
 
@@ -421,9 +427,12 @@ void bus_unit_send_removed_signal(Unit *u) {
 
         assert(u);
 
-        if (set_isempty(u->meta.manager->subscribed) || !u->meta.sent_dbus_new_signal)
+        if (set_isempty(u->meta.manager->subscribed))
                 return;
 
+        if (!u->meta.sent_dbus_new_signal)
+                bus_unit_send_change_signal(u);
+
         if (!(p = unit_dbus_path(u)))
                 goto oom;