summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-07-20 00:00:04 +0200
committerLennart Poettering <lennart@poettering.net>2012-07-20 00:10:32 +0200
commitc74f17d96cccd4cc998fd037cb92046930188c91 (patch)
tree6de40f861594f7042dddac66c492b5047d0c3f91 /src
parent4819ff0358b6317c195fd4b1768e03d09c871070 (diff)
core: drop KillMode parameter from KillUnit() bus call
It made no sense, and since we are documenting the bus calls now and want to include them in our stability promise we really should get it cleaned up sooner, not later.
Diffstat (limited to 'src')
-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
-rw-r--r--src/systemctl/systemctl.c11
11 files changed, 61 insertions, 81 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);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 344dcd3e75..e587cfbfae 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -86,7 +86,6 @@ static bool arg_failed = false;
static bool arg_runtime = false;
static char **arg_wall = NULL;
static const char *arg_kill_who = NULL;
-static const char *arg_kill_mode = NULL;
static int arg_signal = SIGTERM;
static const char *arg_root = NULL;
static usec_t arg_when = 0;
@@ -2140,9 +2139,6 @@ static int kill_unit(DBusConnection *bus, char **args) {
if (!arg_kill_who)
arg_kill_who = "all";
- if (!arg_kill_mode)
- arg_kill_mode = streq(arg_kill_who, "all") ? "control-group" : "process";
-
STRV_FOREACH(name, args+1) {
DBusMessage *reply;
char *n;
@@ -2163,7 +2159,6 @@ static int kill_unit(DBusConnection *bus, char **args) {
b = dbus_message_append_args(m,
DBUS_TYPE_STRING, n ? &n : name,
DBUS_TYPE_STRING, &arg_kill_who,
- DBUS_TYPE_STRING, &arg_kill_mode,
DBUS_TYPE_INT32, &arg_signal,
DBUS_TYPE_INVALID);
free(n);
@@ -4593,7 +4588,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
ARG_ROOT,
ARG_FULL,
ARG_NO_RELOAD,
- ARG_KILL_MODE,
ARG_KILL_WHO,
ARG_NO_ASK_PASSWORD,
ARG_FAILED,
@@ -4625,7 +4619,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
{ "root", required_argument, NULL, ARG_ROOT },
{ "force", no_argument, NULL, ARG_FORCE },
{ "no-reload", no_argument, NULL, ARG_NO_RELOAD },
- { "kill-mode", required_argument, NULL, ARG_KILL_MODE }, /* undocumented on purpose */
{ "kill-who", required_argument, NULL, ARG_KILL_WHO },
{ "signal", required_argument, NULL, 's' },
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
@@ -4771,10 +4764,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
arg_kill_who = optarg;
break;
- case ARG_KILL_MODE:
- arg_kill_mode = optarg;
- break;
-
case 's':
if ((arg_signal = signal_from_string_try_harder(optarg)) < 0) {
log_error("Failed to parse signal string %s.", optarg);