mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
core/socket: introduce SOCKET_STATE_WITH_PROCESS() helper function
This commit is contained in:
parent
28364bc324
commit
6b09c99cba
@ -76,6 +76,20 @@ static int socket_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
|
||||
static int socket_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata);
|
||||
static void flush_ports(Socket *s);
|
||||
|
||||
static bool SOCKET_STATE_WITH_PROCESS(SocketState state) {
|
||||
return IN_SET(state,
|
||||
SOCKET_START_PRE,
|
||||
SOCKET_START_CHOWN,
|
||||
SOCKET_START_POST,
|
||||
SOCKET_STOP_PRE,
|
||||
SOCKET_STOP_PRE_SIGTERM,
|
||||
SOCKET_STOP_PRE_SIGKILL,
|
||||
SOCKET_STOP_POST,
|
||||
SOCKET_FINAL_SIGTERM,
|
||||
SOCKET_FINAL_SIGKILL,
|
||||
SOCKET_CLEANING);
|
||||
}
|
||||
|
||||
static void socket_init(Unit *u) {
|
||||
Socket *s = SOCKET(u);
|
||||
|
||||
@ -1773,18 +1787,7 @@ static void socket_set_state(Socket *s, SocketState state) {
|
||||
old_state = s->state;
|
||||
s->state = state;
|
||||
|
||||
if (!IN_SET(state,
|
||||
SOCKET_START_PRE,
|
||||
SOCKET_START_CHOWN,
|
||||
SOCKET_START_POST,
|
||||
SOCKET_STOP_PRE,
|
||||
SOCKET_STOP_PRE_SIGTERM,
|
||||
SOCKET_STOP_PRE_SIGKILL,
|
||||
SOCKET_STOP_POST,
|
||||
SOCKET_FINAL_SIGTERM,
|
||||
SOCKET_FINAL_SIGKILL,
|
||||
SOCKET_CLEANING)) {
|
||||
|
||||
if (!SOCKET_STATE_WITH_PROCESS(state)) {
|
||||
s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source);
|
||||
socket_unwatch_control_pid(s);
|
||||
s->control_command = NULL;
|
||||
@ -1823,17 +1826,7 @@ static int socket_coldplug(Unit *u) {
|
||||
|
||||
if (pidref_is_set(&s->control_pid) &&
|
||||
pidref_is_unwaited(&s->control_pid) > 0 &&
|
||||
IN_SET(s->deserialized_state,
|
||||
SOCKET_START_PRE,
|
||||
SOCKET_START_CHOWN,
|
||||
SOCKET_START_POST,
|
||||
SOCKET_STOP_PRE,
|
||||
SOCKET_STOP_PRE_SIGTERM,
|
||||
SOCKET_STOP_PRE_SIGKILL,
|
||||
SOCKET_STOP_POST,
|
||||
SOCKET_FINAL_SIGTERM,
|
||||
SOCKET_FINAL_SIGKILL,
|
||||
SOCKET_CLEANING)) {
|
||||
SOCKET_STATE_WITH_PROCESS(s->deserialized_state)) {
|
||||
|
||||
r = unit_watch_pidref(UNIT(s), &s->control_pid, /* exclusive= */ false);
|
||||
if (r < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user