chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
install: implement --start option
[elogind.git]
/
src
/
dbus-manager.c
diff --git
a/src/dbus-manager.c
b/src/dbus-manager.c
index 705a4dc974e857eed44d60f32627fd0eb820c65f..f2a7de738419316dbb6327ad472c9b5e2b2fdbaa 100644
(file)
--- a/
src/dbus-manager.c
+++ b/
src/dbus-manager.c
@@
-56,6
+56,11
@@
" <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
" <arg name=\"job\" type=\"o\" direction=\"out\"/>\n" \
" </method>\n" \
" <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
" <arg name=\"job\" type=\"o\" direction=\"out\"/>\n" \
" </method>\n" \
+ " <method name=\"TryRestartUnit\">\n" \
+ " <arg name=\"name\" type=\"s\" direction=\"in\"/>\n" \
+ " <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
+ " <arg name=\"job\" type=\"o\" direction=\"out\"/>\n" \
+ " </method>\n" \
" <method name=\"GetJob\">\n" \
" <arg name=\"id\" type=\"u\" direction=\"in\"/>\n" \
" <arg name=\"job\" type=\"o\" direction=\"out\"/>\n" \
" <method name=\"GetJob\">\n" \
" <arg name=\"id\" type=\"u\" direction=\"in\"/>\n" \
" <arg name=\"job\" type=\"o\" direction=\"out\"/>\n" \
@@
-287,6
+292,8
@@
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
job_type = JOB_RELOAD;
else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "RestartUnit"))
job_type = JOB_RESTART;
job_type = JOB_RELOAD;
else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "RestartUnit"))
job_type = JOB_RESTART;
+ else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "TryRestartUnit"))
+ job_type = JOB_TRY_RESTART;
else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetJob")) {
uint32_t id;
Job *j;
else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetJob")) {
uint32_t id;
Job *j;
@@
-452,14
+459,25
@@
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Subscribe")) {
char *client;
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Subscribe")) {
char *client;
+ Set *s;
+
+ if (!(s = BUS_CONNECTION_SUBSCRIBED(m, connection))) {
+ if (!(s = set_new(string_hash_func, string_compare_func)))
+ goto oom;
+
+ if (!(dbus_connection_set_data(connection, m->subscribed_data_slot, s, NULL))) {
+ set_free(s);
+ goto oom;
+ }
+ }
if (!(client = strdup(dbus_message_get_sender(message))))
goto oom;
if (!(client = strdup(dbus_message_get_sender(message))))
goto oom;
- r = set_put(m->subscribed, client);
-
- if (r < 0)
+ if ((r = set_put(s, client)) < 0) {
+ free(client);
return bus_send_error_reply(m, connection, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
+ }
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
@@
-467,7
+485,7
@@
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Unsubscribe")) {
char *client;
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Unsubscribe")) {
char *client;
- if (!(client = set_remove(
m->subscribed
, (char*) dbus_message_get_sender(message))))
+ if (!(client = set_remove(
BUS_CONNECTION_SUBSCRIBED(m, connection)
, (char*) dbus_message_get_sender(message))))
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
free(client);
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
free(client);
@@
-702,6
+720,11
@@
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
if ((r = manager_add_job(m, job_type, u, mode, true, &j)) < 0)
return bus_send_error_reply(m, connection, message, NULL, r);
if ((r = manager_add_job(m, job_type, u, mode, true, &j)) < 0)
return bus_send_error_reply(m, connection, message, NULL, r);
+ if (!(j->bus_client = strdup(dbus_message_get_sender(message))))
+ goto oom;
+
+ j->bus = connection;
+
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
@@
-713,6
+736,7
@@
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID))
goto oom;
DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID))
goto oom;
+
}
free(path);
}
free(path);