summaryrefslogtreecommitdiffstats
path: root/src/core/swap.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-09-25 19:57:52 +0200
committerLennart Poettering <lennart@poettering.net>2017-09-26 16:17:22 +0200
commitdedf37190986be8bc1447d2a1ab8a877e9dce2af (patch)
treeb51b1cd14f8684aba9ff2bfc79e2094756682b5a /src/core/swap.c
parentswap: adjust swap.c in a similar way to what we just did to mount.c (diff)
downloadsystemd-dedf37190986be8bc1447d2a1ab8a877e9dce2af.tar.xz
systemd-dedf37190986be8bc1447d2a1ab8a877e9dce2af.zip
swap: introduce SWAP_STATE_WITH_PROCESS() similar to MOUNT_STATE_WITH_PROCESS()
Diffstat (limited to '')
-rw-r--r--src/core/swap.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/core/swap.c b/src/core/swap.c
index 0cf03fc354..6db1c0df69 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -57,6 +57,15 @@ static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
static int swap_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata);
static int swap_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata);
+static bool SWAP_STATE_WITH_PROCESS(SwapState state) {
+ return IN_SET(state,
+ SWAP_ACTIVATING,
+ SWAP_ACTIVATING_DONE,
+ SWAP_DEACTIVATING,
+ SWAP_DEACTIVATING_SIGTERM,
+ SWAP_DEACTIVATING_SIGKILL);
+}
+
static void swap_unset_proc_swaps(Swap *s) {
assert(s);
@@ -485,12 +494,7 @@ static void swap_set_state(Swap *s, SwapState state) {
old_state = s->state;
s->state = state;
- if (!IN_SET(state,
- SWAP_ACTIVATING,
- SWAP_ACTIVATING_DONE,
- SWAP_DEACTIVATING,
- SWAP_DEACTIVATING_SIGTERM,
- SWAP_DEACTIVATING_SIGKILL)) {
+ if (!SWAP_STATE_WITH_PROCESS(state)) {
s->timer_event_source = sd_event_source_unref(s->timer_event_source);
swap_unwatch_control_pid(s);
s->control_command = NULL;
@@ -530,12 +534,7 @@ static int swap_coldplug(Unit *u) {
if (s->control_pid > 0 &&
pid_is_unwaited(s->control_pid) &&
- IN_SET(new_state,
- SWAP_ACTIVATING,
- SWAP_ACTIVATING_DONE,
- SWAP_DEACTIVATING,
- SWAP_DEACTIVATING_SIGTERM,
- SWAP_DEACTIVATING_SIGKILL)) {
+ SWAP_STATE_WITH_PROCESS(new_state)) {
r = unit_watch_pid(UNIT(s), s->control_pid);
if (r < 0)