summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dbus-manager.c19
-rw-r--r--src/core/dbus-unit.c18
-rw-r--r--src/core/dbus-unit.h1
-rw-r--r--src/core/kill.h2
-rw-r--r--src/core/mount.c18
-rw-r--r--src/core/service.c25
-rw-r--r--src/core/socket.c18
-rw-r--r--src/core/swap.c18
-rw-r--r--src/core/unit.c8
-rw-r--r--src/core/unit.h4
10 files changed, 61 insertions, 70 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 925e87cc57..c341d36a6b 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -94,7 +94,6 @@
" <method name=\"KillUnit\">\n" \
" <arg name=\"name\" type=\"s\" direction=\"in\"/>\n" \
" <arg name=\"who\" type=\"s\" direction=\"in\"/>\n" \
- " <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
" <arg name=\"signal\" type=\"i\" direction=\"in\"/>\n" \
" </method>\n" \
" <method name=\"ResetFailedUnit\">\n" \
@@ -665,10 +664,9 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
reload_if_possible = true;
job_type = JOB_TRY_RESTART;
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "KillUnit")) {
- const char *name, *swho, *smode;
+ const char *name, *swho;
int32_t signo;
Unit *u;
- KillMode mode;
KillWho who;
if (!dbus_message_get_args(
@@ -676,7 +674,6 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
&error,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_STRING, &swho,
- DBUS_TYPE_STRING, &smode,
DBUS_TYPE_INT32, &signo,
DBUS_TYPE_INVALID))
return bus_send_error_reply(connection, message, &error, -EINVAL);
@@ -689,23 +686,17 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
return bus_send_error_reply(connection, message, &error, -EINVAL);
}
- if (isempty(smode))
- mode = KILL_CONTROL_GROUP;
- else {
- mode = kill_mode_from_string(smode);
- if (mode < 0)
- return bus_send_error_reply(connection, message, &error, -EINVAL);
- }
-
if (signo <= 0 || signo >= _NSIG)
return bus_send_error_reply(connection, message, &error, -EINVAL);
- if (!(u = manager_get_unit(m, name))) {
+ u = manager_get_unit(m, name);
+ if (!u) {
dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name);
return bus_send_error_reply(connection, message, &error, -ENOENT);
}
- if ((r = unit_kill(u, who, mode, signo, &error)) < 0)
+ r = unit_kill(u, who, signo, &error);
+ if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
if (!(reply = dbus_message_new_method_return(message)))
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 21145873ea..2d2f378ba4 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -431,9 +431,8 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn
reload_if_possible = true;
job_type = JOB_TRY_RESTART;
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Kill")) {
- const char *swho, *smode;
+ const char *swho;
int32_t signo;
- KillMode mode;
KillWho who;
int r;
@@ -441,7 +440,6 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn
message,
&error,
DBUS_TYPE_STRING, &swho,
- DBUS_TYPE_STRING, &smode,
DBUS_TYPE_INT32, &signo,
DBUS_TYPE_INVALID))
return bus_send_error_reply(connection, message, &error, -EINVAL);
@@ -454,21 +452,15 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn
return bus_send_error_reply(connection, message, &error, -EINVAL);
}
- if (isempty(smode))
- mode = KILL_CONTROL_GROUP;
- else {
- mode = kill_mode_from_string(smode);
- if (mode < 0)
- return bus_send_error_reply(connection, message, &error, -EINVAL);
- }
-
if (signo <= 0 || signo >= _NSIG)
return bus_send_error_reply(connection, message, &error, -EINVAL);
- if ((r = unit_kill(u, who, mode, signo, &error)) < 0)
+ r = unit_kill(u, who, signo, &error);
+ if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
- if (!(reply = dbus_message_new_method_return(message)))
+ reply = dbus_message_new_method_return(message);
+ if (!reply)
goto oom;
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "ResetFailed")) {
diff --git a/src/core/dbus-unit.h b/src/core/dbus-unit.h
index 5a3a9be534..7ab355c279 100644
--- a/src/core/dbus-unit.h
+++ b/src/core/dbus-unit.h
@@ -58,7 +58,6 @@
" </method>\n" \
" <method name=\"Kill\">\n" \
" <arg name=\"who\" type=\"s\" direction=\"in\"/>\n" \
- " <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
" <arg name=\"signal\" type=\"i\" direction=\"in\"/>\n" \
" </method>\n" \
" <method name=\"ResetFailed\"/>\n" \
diff --git a/src/core/kill.h b/src/core/kill.h
index 4f88239271..3c9b0ab8db 100644
--- a/src/core/kill.h
+++ b/src/core/kill.h
@@ -27,6 +27,7 @@ typedef struct KillContext KillContext;
#include <stdio.h>
typedef enum KillMode {
+ /* The kill mode is a property of a unit. */
KILL_CONTROL_GROUP = 0,
KILL_PROCESS,
KILL_NONE,
@@ -41,6 +42,7 @@ struct KillContext {
};
typedef enum KillWho {
+ /* Kill who is a property of an operation */
KILL_MAIN,
KILL_CONTROL,
KILL_ALL,
diff --git a/src/core/mount.c b/src/core/mount.c
index 82c64ff79b..5709db2266 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1708,7 +1708,7 @@ static void mount_reset_failed(Unit *u) {
m->reload_result = MOUNT_SUCCESS;
}
-static int mount_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *error) {
+static int mount_kill(Unit *u, KillWho who, int signo, DBusError *error) {
Mount *m = MOUNT(u);
int r = 0;
Set *pid_set = NULL;
@@ -1730,23 +1730,25 @@ static int mount_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError
if (kill(m->control_pid, signo) < 0)
r = -errno;
- if (who == KILL_ALL && mode == KILL_CONTROL_GROUP) {
+ if (who == KILL_ALL) {
int q;
- if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
+ pid_set = set_new(trivial_hash_func, trivial_compare_func);
+ if (!pid_set)
return -ENOMEM;
/* Exclude the control pid from being killed via the cgroup */
- if (m->control_pid > 0)
- if ((q = set_put(pid_set, LONG_TO_PTR(m->control_pid))) < 0) {
+ if (m->control_pid > 0) {
+ q = set_put(pid_set, LONG_TO_PTR(m->control_pid));
+ if (q < 0) {
r = q;
goto finish;
}
+ }
q = cgroup_bonding_kill_list(UNIT(m)->cgroup_bondings, signo, false, false, pid_set, NULL);
- if (q < 0)
- if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
- r = q;
+ if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
+ r = q;
}
finish:
diff --git a/src/core/service.c b/src/core/service.c
index 567e9a4eb3..78f9a59c7f 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3673,7 +3673,7 @@ static void service_reset_failed(Unit *u) {
RATELIMIT_RESET(s->start_limit);
}
-static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *error) {
+static int service_kill(Unit *u, KillWho who, int signo, DBusError *error) {
Service *s = SERVICE(u);
int r = 0;
Set *pid_set = NULL;
@@ -3700,28 +3700,33 @@ static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusErro
if (kill(s->main_pid, signo) < 0)
r = -errno;
- if (who == KILL_ALL && mode == KILL_CONTROL_GROUP) {
+ if (who == KILL_ALL) {
int q;
- if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
+ pid_set = set_new(trivial_hash_func, trivial_compare_func);
+ if (!pid_set)
return -ENOMEM;
/* Exclude the control/main pid from being killed via the cgroup */
- if (s->control_pid > 0)
- if ((q = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0) {
+ if (s->control_pid > 0) {
+ q = set_put(pid_set, LONG_TO_PTR(s->control_pid));
+ if (q < 0) {
r = q;
goto finish;
}
+ }
- if (s->main_pid > 0)
- if ((q = set_put(pid_set, LONG_TO_PTR(s->main_pid))) < 0) {
+ if (s->main_pid > 0) {
+ q = set_put(pid_set, LONG_TO_PTR(s->main_pid));
+ if (q < 0) {
r = q;
goto finish;
}
+ }
+
q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, false, pid_set, NULL);
- if (q < 0)
- if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
- r = q;
+ if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
+ r = q;
}
finish:
diff --git a/src/core/socket.c b/src/core/socket.c
index 6d417878b5..19b463e6a4 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -2104,7 +2104,7 @@ static void socket_reset_failed(Unit *u) {
s->result = SOCKET_SUCCESS;
}
-static int socket_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *error) {
+static int socket_kill(Unit *u, KillWho who, int signo, DBusError *error) {
Socket *s = SOCKET(u);
int r = 0;
Set *pid_set = NULL;
@@ -2126,23 +2126,25 @@ static int socket_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError
if (kill(s->control_pid, signo) < 0)
r = -errno;
- if (who == KILL_ALL && mode == KILL_CONTROL_GROUP) {
+ if (who == KILL_ALL) {
int q;
- if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
+ pid_set = set_new(trivial_hash_func, trivial_compare_func);
+ if (!pid_set)
return -ENOMEM;
/* Exclude the control pid from being killed via the cgroup */
- if (s->control_pid > 0)
- if ((q = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0) {
+ if (s->control_pid > 0) {
+ q = set_put(pid_set, LONG_TO_PTR(s->control_pid));
+ if (q < 0) {
r = q;
goto finish;
}
+ }
q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, false, pid_set, NULL);
- if (q < 0)
- if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
- r = q;
+ if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
+ r = q;
}
finish:
diff --git a/src/core/swap.c b/src/core/swap.c
index 03993b1e60..91bb0215b1 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -1260,7 +1260,7 @@ static void swap_reset_failed(Unit *u) {
s->result = SWAP_SUCCESS;
}
-static int swap_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *error) {
+static int swap_kill(Unit *u, KillWho who, int signo, DBusError *error) {
Swap *s = SWAP(u);
int r = 0;
Set *pid_set = NULL;
@@ -1282,23 +1282,25 @@ static int swap_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *
if (kill(s->control_pid, signo) < 0)
r = -errno;
- if (who == KILL_ALL && mode == KILL_CONTROL_GROUP) {
+ if (who == KILL_ALL) {
int q;
- if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
+ pid_set = set_new(trivial_hash_func, trivial_compare_func);
+ if (!pid_set)
return -ENOMEM;
/* Exclude the control pid from being killed via the cgroup */
- if (s->control_pid > 0)
- if ((q = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0) {
+ if (s->control_pid > 0) {
+ q = set_put(pid_set, LONG_TO_PTR(s->control_pid));
+ if (q < 0) {
r = q;
goto finish;
}
+ }
q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, false, pid_set, NULL);
- if (q < 0)
- if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
- r = q;
+ if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
+ r = q;
}
finish:
diff --git a/src/core/unit.c b/src/core/unit.c
index ae6f69183d..3b416f945f 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2721,20 +2721,16 @@ bool unit_pending_active(Unit *u) {
return false;
}
-int unit_kill(Unit *u, KillWho w, KillMode m, int signo, DBusError *error) {
+int unit_kill(Unit *u, KillWho w, int signo, DBusError *error) {
assert(u);
assert(w >= 0 && w < _KILL_WHO_MAX);
- assert(m >= 0 && m < _KILL_MODE_MAX);
assert(signo > 0);
assert(signo < _NSIG);
- if (m == KILL_NONE)
- return 0;
-
if (!UNIT_VTABLE(u)->kill)
return -ENOTSUP;
- return UNIT_VTABLE(u)->kill(u, w, m, signo, error);
+ return UNIT_VTABLE(u)->kill(u, w, signo, error);
}
int unit_following_set(Unit *u, Set **s) {
diff --git a/src/core/unit.h b/src/core/unit.h
index 635293ffb6..f004179894 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -293,7 +293,7 @@ struct UnitVTable {
int (*stop)(Unit *u);
int (*reload)(Unit *u);
- int (*kill)(Unit *u, KillWho w, KillMode m, int signo, DBusError *error);
+ int (*kill)(Unit *u, KillWho w, int signo, DBusError *error);
bool (*can_reload)(Unit *u);
@@ -468,7 +468,7 @@ int unit_start(Unit *u);
int unit_stop(Unit *u);
int unit_reload(Unit *u);
-int unit_kill(Unit *u, KillWho w, KillMode m, int signo, DBusError *error);
+int unit_kill(Unit *u, KillWho w, int signo, DBusError *error);
void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success);