diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-28 20:05:49 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-12-07 17:35:32 +0100 |
commit | 31135818e41fb7d779da3a74e4ff50df6a20f2fd (patch) | |
tree | e189c8191fc753b37a3399638ff5157a56343b17 /src/core/swap.c | |
parent | mount: flush out cycle state on DEAD→MOUNTED only, not the other way round (diff) | |
download | systemd-31135818e41fb7d779da3a74e4ff50df6a20f2fd.tar.xz systemd-31135818e41fb7d779da3a74e4ff50df6a20f2fd.zip |
swap: flush out state when activating a unit, not when deactivating it
This is similar to the previous commit which did the same change for
mount units.
Diffstat (limited to 'src/core/swap.c')
-rw-r--r-- | src/core/swap.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/core/swap.c b/src/core/swap.c index 90207a48fa..bbcf886458 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -813,6 +813,14 @@ fail: swap_enter_dead_or_active(s, SWAP_FAILURE_RESOURCES); } +static void swap_cycle_clear(Swap *s) { + assert(s); + + s->result = SWAP_SUCCESS; + exec_command_reset_status_array(s->exec_command, _SWAP_EXEC_COMMAND_MAX); + UNIT(s)->reset_accounting = true; +} + static int swap_start(Unit *u) { Swap *s = SWAP(u), *other; int r; @@ -852,11 +860,7 @@ static int swap_start(Unit *u) { if (r < 0) return r; - s->result = SWAP_SUCCESS; - exec_command_reset_status_array(s->exec_command, _SWAP_EXEC_COMMAND_MAX); - - u->reset_accounting = true; - + swap_cycle_clear(s); swap_enter_activating(s); return 1; } @@ -1183,7 +1187,8 @@ static int swap_dispatch_io(sd_event_source *source, int fd, uint32_t revents, v case SWAP_DEAD: case SWAP_FAILED: - (void) unit_acquire_invocation_id(UNIT(swap)); + (void) unit_acquire_invocation_id(u); + swap_cycle_clear(swap); swap_enter_active(swap, SWAP_SUCCESS); break; |