Fix confusion between killer and prey
"who" is the entity doing the killing, "whom" is the target.
Follow-up for 4ccde410a3.
This commit is contained in:
@@ -123,7 +123,7 @@ int bus_machine_method_kill(sd_bus_message *message, void *userdata, sd_bus_erro
|
||||
Machine *m = ASSERT_PTR(userdata);
|
||||
const char *swho;
|
||||
int32_t signo;
|
||||
KillWho who;
|
||||
KillWhom whom;
|
||||
int r;
|
||||
|
||||
assert(message);
|
||||
@@ -133,10 +133,10 @@ int bus_machine_method_kill(sd_bus_message *message, void *userdata, sd_bus_erro
|
||||
return r;
|
||||
|
||||
if (isempty(swho))
|
||||
who = KILL_ALL;
|
||||
whom = KILL_ALL;
|
||||
else {
|
||||
who = kill_who_from_string(swho);
|
||||
if (who < 0)
|
||||
whom = kill_whom_from_string(swho);
|
||||
if (whom < 0)
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho);
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ int bus_machine_method_kill(sd_bus_message *message, void *userdata, sd_bus_erro
|
||||
if (r == 0)
|
||||
return 1; /* Will call us back */
|
||||
|
||||
r = machine_kill(m, who, signo);
|
||||
r = machine_kill(m, whom, signo);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -1293,7 +1293,7 @@ static const sd_bus_vtable machine_vtable[] = {
|
||||
bus_machine_method_terminate,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD_WITH_ARGS("Kill",
|
||||
SD_BUS_ARGS("s", who, "i", signal),
|
||||
SD_BUS_ARGS("s", whom, "i", signal),
|
||||
SD_BUS_NO_RESULT,
|
||||
bus_machine_method_kill,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
|
||||
@@ -609,7 +609,7 @@ MachineState machine_get_state(Machine *s) {
|
||||
return MACHINE_RUNNING;
|
||||
}
|
||||
|
||||
int machine_kill(Machine *m, KillWho who, int signo) {
|
||||
int machine_kill(Machine *m, KillWhom whom, int signo) {
|
||||
assert(m);
|
||||
|
||||
if (!IN_SET(m->class, MACHINE_VM, MACHINE_CONTAINER))
|
||||
@@ -618,7 +618,7 @@ int machine_kill(Machine *m, KillWho who, int signo) {
|
||||
if (!m->unit)
|
||||
return -ESRCH;
|
||||
|
||||
if (who == KILL_LEADER) /* If we shall simply kill the leader, do so directly */
|
||||
if (whom == KILL_LEADER) /* If we shall simply kill the leader, do so directly */
|
||||
return pidref_kill(&m->leader, signo);
|
||||
|
||||
/* Otherwise, make PID 1 do it for us, for the entire cgroup */
|
||||
@@ -920,9 +920,9 @@ static const char* const machine_state_table[_MACHINE_STATE_MAX] = {
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(machine_state, MachineState);
|
||||
|
||||
static const char* const kill_who_table[_KILL_WHO_MAX] = {
|
||||
static const char* const kill_whom_table[_KILL_WHOM_MAX] = {
|
||||
[KILL_LEADER] = "leader",
|
||||
[KILL_ALL] = "all"
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(kill_who, KillWho);
|
||||
DEFINE_STRING_TABLE_LOOKUP(kill_whom, KillWhom);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct Machine Machine;
|
||||
typedef enum KillWho KillWho;
|
||||
typedef enum KillWhom KillWhom;
|
||||
|
||||
#include "list.h"
|
||||
#include "machined.h"
|
||||
@@ -26,11 +26,11 @@ typedef enum MachineClass {
|
||||
_MACHINE_CLASS_INVALID = -EINVAL,
|
||||
} MachineClass;
|
||||
|
||||
enum KillWho {
|
||||
enum KillWhom {
|
||||
KILL_LEADER,
|
||||
KILL_ALL,
|
||||
_KILL_WHO_MAX,
|
||||
_KILL_WHO_INVALID = -EINVAL,
|
||||
_KILL_WHOM_MAX,
|
||||
_KILL_WHOM_INVALID = -EINVAL,
|
||||
};
|
||||
|
||||
struct Machine {
|
||||
@@ -81,7 +81,7 @@ int machine_stop(Machine *m);
|
||||
int machine_finalize(Machine *m);
|
||||
int machine_save(Machine *m);
|
||||
int machine_load(Machine *m);
|
||||
int machine_kill(Machine *m, KillWho who, int signo);
|
||||
int machine_kill(Machine *m, KillWhom whom, int signo);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Machine*, machine_free);
|
||||
|
||||
@@ -95,8 +95,8 @@ MachineClass machine_class_from_string(const char *s) _pure_;
|
||||
const char* machine_state_to_string(MachineState t) _const_;
|
||||
MachineState machine_state_from_string(const char *s) _pure_;
|
||||
|
||||
const char *kill_who_to_string(KillWho k) _const_;
|
||||
KillWho kill_who_from_string(const char *s) _pure_;
|
||||
const char *kill_whom_to_string(KillWhom k) _const_;
|
||||
KillWhom kill_whom_from_string(const char *s) _pure_;
|
||||
|
||||
int machine_openpt(Machine *m, int flags, char **ret_slave);
|
||||
int machine_open_terminal(Machine *m, const char *path, int mode);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
int main(int argc, char **argv) {
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
test_table(kill_who, KILL_WHO);
|
||||
test_table(kill_whom, KILL_WHOM);
|
||||
test_table(machine_class, MACHINE_CLASS);
|
||||
test_table(machine_state, MACHINE_STATE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user