core: port unit_main_pid() + unit_control_pid() to PidRef and drop unit_kill_common()

This ports over unit_main_pid() + unit_control_pid() to return PidRef*
pointers (which also means the underlying UnitVTable function pointers
are changed accordingly).

This then uses te functions to simplify the unit_kill() call, by
avoiding the kill() vtable indirection and instead just suing
unit_main_pid() and unit_control_pid() directly.
This commit is contained in:
Lennart Poettering
2023-09-18 19:08:09 +02:00
parent a0d1659c23
commit 37eb258e91
11 changed files with 60 additions and 133 deletions
+2 -11
View File
@@ -3382,10 +3382,6 @@ static void socket_trigger_notify(Unit *u, Unit *other) {
socket_set_state(s, SOCKET_RUNNING);
}
static int socket_kill(Unit *u, KillWho who, int signo, int code, int value, sd_bus_error *error) {
return unit_kill_common(u, who, signo, code, value, -1, SOCKET(u)->control_pid.pid, error);
}
static int socket_get_timeout(Unit *u, usec_t *timeout) {
Socket *s = SOCKET(u);
usec_t t;
@@ -3414,12 +3410,8 @@ char *socket_fdname(Socket *s) {
return s->fdname ?: UNIT(s)->id;
}
static int socket_control_pid(Unit *u) {
Socket *s = SOCKET(u);
assert(s);
return s->control_pid.pid;
static PidRef *socket_control_pid(Unit *u) {
return &ASSERT_PTR(SOCKET(u))->control_pid;
}
static int socket_clean(Unit *u, ExecCleanMask mask) {
@@ -3576,7 +3568,6 @@ const UnitVTable socket_vtable = {
.start = socket_start,
.stop = socket_stop,
.kill = socket_kill,
.clean = socket_clean,
.can_clean = socket_can_clean,