chiark / gitweb /
sd-event: allow disabling event sources when an event object is dying anyway
authorLennart Poettering <lennart@poettering.net>
Mon, 5 May 2014 21:48:25 +0000 (23:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 5 May 2014 21:48:25 +0000 (23:48 +0200)
src/libsystemd/sd-event/sd-event.c

index 70770fc..4797087 100644 (file)
@@ -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;