1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

sd-event: allow disabling event sources when an event object is dying anyway

This commit is contained in:
Lennart Poettering 2014-05-05 23:48:25 +02:00
parent 59bc1fd776
commit cc567911ba

View 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;