core: all unit types that watch control PIDs should use the same logic

When coldplugging the unit state, make sure to follow the same basic
logic for all unit types: always verify whether the control PID is still
a waitable process before proceeding.
This commit is contained in:
Lennart Poettering
2015-10-27 17:59:45 +01:00
parent 76583ef261
commit c386f58864
4 changed files with 29 additions and 31 deletions
+3 -4
View File
@@ -364,10 +364,9 @@ static int busname_coldplug(Unit *u) {
if (n->deserialized_state == n->state)
return 0;
if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {
if (n->control_pid <= 0)
return -EBADMSG;
if (n->control_pid > 0 &&
pid_is_unwaited(n->control_pid) &&
IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {
r = unit_watch_pid(UNIT(n), n->control_pid);
if (r < 0)
+13 -13
View File
@@ -632,19 +632,19 @@ static int mount_coldplug(Unit *u) {
if (new_state == m->state)
return 0;
if (new_state == MOUNT_MOUNTING ||
new_state == MOUNT_MOUNTING_DONE ||
new_state == MOUNT_REMOUNTING ||
new_state == MOUNT_UNMOUNTING ||
new_state == MOUNT_MOUNTING_SIGTERM ||
new_state == MOUNT_MOUNTING_SIGKILL ||
new_state == MOUNT_UNMOUNTING_SIGTERM ||
new_state == MOUNT_UNMOUNTING_SIGKILL ||
new_state == MOUNT_REMOUNTING_SIGTERM ||
new_state == MOUNT_REMOUNTING_SIGKILL) {
if (m->control_pid <= 0)
return -EBADMSG;
if (m->control_pid > 0 &&
pid_is_unwaited(m->control_pid) &&
IN_SET(new_state,
MOUNT_MOUNTING,
MOUNT_MOUNTING_DONE,
MOUNT_REMOUNTING,
MOUNT_UNMOUNTING,
MOUNT_MOUNTING_SIGTERM,
MOUNT_MOUNTING_SIGKILL,
MOUNT_UNMOUNTING_SIGTERM,
MOUNT_UNMOUNTING_SIGKILL,
MOUNT_REMOUNTING_SIGTERM,
MOUNT_REMOUNTING_SIGKILL)) {
r = unit_watch_pid(UNIT(m), m->control_pid);
if (r < 0)
+3 -4
View File
@@ -1455,7 +1455,9 @@ static int socket_coldplug(Unit *u) {
if (s->deserialized_state == s->state)
return 0;
if (IN_SET(s->deserialized_state,
if (s->control_pid > 0 &&
pid_is_unwaited(s->control_pid) &&
IN_SET(s->deserialized_state,
SOCKET_START_PRE,
SOCKET_START_CHOWN,
SOCKET_START_POST,
@@ -1466,9 +1468,6 @@ static int socket_coldplug(Unit *u) {
SOCKET_FINAL_SIGTERM,
SOCKET_FINAL_SIGKILL)) {
if (s->control_pid <= 0)
return -EBADMSG;
r = unit_watch_pid(UNIT(s), s->control_pid);
if (r < 0)
return r;
+10 -10
View File
@@ -528,16 +528,16 @@ static int swap_coldplug(Unit *u) {
if (new_state == s->state)
return 0;
if (new_state == SWAP_ACTIVATING ||
new_state == SWAP_ACTIVATING_SIGTERM ||
new_state == SWAP_ACTIVATING_SIGKILL ||
new_state == SWAP_ACTIVATING_DONE ||
new_state == SWAP_DEACTIVATING ||
new_state == SWAP_DEACTIVATING_SIGTERM ||
new_state == SWAP_DEACTIVATING_SIGKILL) {
if (s->control_pid <= 0)
return -EBADMSG;
if (s->control_pid > 0 &&
pid_is_unwaited(s->control_pid) &&
IN_SET(new_state,
SWAP_ACTIVATING,
SWAP_ACTIVATING_SIGTERM,
SWAP_ACTIVATING_SIGKILL,
SWAP_ACTIVATING_DONE,
SWAP_DEACTIVATING,
SWAP_DEACTIVATING_SIGTERM,
SWAP_DEACTIVATING_SIGKILL)) {
r = unit_watch_pid(UNIT(s), s->control_pid);
if (r < 0)