]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: drop KillMode parameter from KillUnit() bus call
authorLennart Poettering <lennart@poettering.net>
Thu, 19 Jul 2012 22:00:04 +0000 (00:00 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 19 Jul 2012 22:10:32 +0000 (00:10 +0200)
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.

src/core/dbus-manager.c
src/core/dbus-unit.c
src/core/dbus-unit.h
src/core/kill.h
src/core/mount.c
src/core/service.c
src/core/socket.c
src/core/swap.c
src/core/unit.c
src/core/unit.h
src/systemctl/systemctl.c

index 925e87cc570da514efe31cb697c8f594c6af6ccb..c341d36a6bb926cdccfcbd9aa319c07a032fe264 100644 (file)
@@ -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)))
index 21145873ea4503c0a9fd50c13a236b54e956f8c8..2d2f378ba47ab5458f44967b52e69dce65b25b0e 100644 (file)
@@ -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")) {
index 5a3a9be5349779533f77595b41e57247a924c733..7ab355c27972f891fae4189dd3eddc5396c641ad 100644 (file)
@@ -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"                            \
index 4f8823927113017400659eaff8e1be54691b3e66..3c9b0ab8dbacb61938123d6cfe64af5c11ef771c 100644 (file)
@@ -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,
index 82c64ff79b5d697be155bf54bb4d86ae30b0836b..5709db2266196c1a9e82ce25f35ae18bdb9a1598 100644 (file)
@@ -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:
index 567e9a4eb316c6e727b2d94b1f83f72f9f4613db..78f9a59c7f2cf684524a387efd2487d78cef0f56 100644 (file)
@@ -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:
index 6d417878b5e1b5c48d9b29efa4b313d5779aff9b..19b463e6a452553c6cc922f79764ab796bd5202f 100644 (file)
@@ -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:
index 03993b1e60ecffdc81a8186b72e3c62246a0c1f8..91bb0215b1efee52d62c97ea26659e358bdd4fa7 100644 (file)
@@ -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:
index ae6f69183d284055ec624391c9670a80a1a8a3e8..3b416f945fcc20ccac996d6322ff43103f0bfbe1 100644 (file)
@@ -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) {
index 635293ffb61b2bbce1f3c45428942875465953ee..f0041798947a392c43e72f391178264e18a4c686 100644 (file)
@@ -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);
 
index 344dcd3e753268ee029cb58336282df048a52f95..e587cfbfae552e0b10fc1d33be62e29ee0d043d8 100644 (file)
@@ -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);