summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-05-05 23:48:25 +0200
committerLennart Poettering <lennart@poettering.net>2014-05-05 23:48:25 +0200
commitcc567911ba790931743c18332b2476e8c4accf64 (patch)
tree7b3d3d8b857011532489f31dd0cd066eb314c0bd /src
parent59bc1fd776b5270bcabe3c536852afd0c892fbe1 (diff)
sd-event: allow disabling event sources when an event object is dying anyway
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-event/sd-event.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 70770fc7ad..47970879da 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -1313,9 +1313,13 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
assert_return(s, -EINVAL);
assert_return(m == SD_EVENT_OFF || m == SD_EVENT_ON || m == SD_EVENT_ONESHOT, -EINVAL);
- assert_return(s->event->state != SD_EVENT_FINISHED, -ESTALE);
assert_return(!event_pid_changed(s->event), -ECHILD);
+ /* If we are dead anyway, we are fine with turning off
+ * sources, but everything else needs to fail. */
+ if (s->event->state == SD_EVENT_FINISHED)
+ return m == SD_EVENT_OFF ? 0 : -ESTALE;
+
if (s->enabled == m)
return 0;