summaryrefslogtreecommitdiff
path: root/src/core/swap.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-05-10 10:22:07 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-05-12 12:08:52 +0200
commit5dcadb4c8320f6a7b8a9353404874d43668e4648 (patch)
tree2039780ceecdcd107951df33b980089ba42d0704 /src/core/swap.c
parent8808d3289e6a595828ef38b05c0f2c7706be1dae (diff)
downloadsystemd-5dcadb4c8320f6a7b8a9353404874d43668e4648.tar.gz
core: disable event sources before unreffing them
This mirrors the change done for systemd-resolved in 97935302283729c9206b84f5e00b1aff0f78ad19. Quoting that patch: > We generally operate on the assumption that a source is "gone" as soon as we > unref it. This is generally true because we have the only reference. But if > something else holds the reference, our unref doesn't really stop the source > and it could fire again. In particular, we take temporary references from sd-event code, and when called from an sd-event callback, we could temporarily see this elevated reference count. This patch doesn't seem to change anything, but I think it's nicer to do the same change as in other places and not rely on _unref() immediately disabling the source.
Diffstat (limited to 'src/core/swap.c')
-rw-r--r--src/core/swap.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/swap.c b/src/core/swap.c
index a81b1928b8..a3b259abb6 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -179,7 +179,7 @@ static void swap_done(Unit *u) {
swap_unwatch_control_pid(s);
- s->timer_event_source = sd_event_source_unref(s->timer_event_source);
+ s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source);
}
static int swap_arm_timer(Swap *s, usec_t usec) {
@@ -554,7 +554,7 @@ static void swap_set_state(Swap *s, SwapState state) {
s->state = state;
if (!SWAP_STATE_WITH_PROCESS(state)) {
- s->timer_event_source = sd_event_source_unref(s->timer_event_source);
+ s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source);
swap_unwatch_control_pid(s);
s->control_command = NULL;
s->control_command_id = _SWAP_EXEC_COMMAND_INVALID;
@@ -715,7 +715,7 @@ static int swap_spawn(Swap *s, ExecCommand *c, pid_t *_pid) {
return 0;
fail:
- s->timer_event_source = sd_event_source_unref(s->timer_event_source);
+ s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source);
return r;
}
@@ -1373,7 +1373,7 @@ static int swap_following_set(Unit *u, Set **_set) {
static void swap_shutdown(Manager *m) {
assert(m);
- m->swap_event_source = sd_event_source_unref(m->swap_event_source);
+ m->swap_event_source = sd_event_source_disable_unref(m->swap_event_source);
m->proc_swaps = safe_fclose(m->proc_swaps);
m->swaps_by_devnode = hashmap_free(m->swaps_by_devnode);
}
@@ -1577,7 +1577,7 @@ static int swap_clean(Unit *u, ExecCleanMask mask) {
fail:
log_unit_warning_errno(u, r, "Failed to initiate cleaning: %m");
s->clean_result = SWAP_FAILURE_RESOURCES;
- s->timer_event_source = sd_event_source_unref(s->timer_event_source);
+ s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source);
return r;
}