[systemd-commits] src/libsystemd

David Herrmann dvdhrm at kemper.freedesktop.org
Wed Feb 19 13:27:24 CET 2014


 src/libsystemd/sd-event/sd-event.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 7a0d4a3d16855bac2ce2f2973122dae1ed069dff
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Wed Feb 19 13:24:38 2014 +0100

    event: fix crash on child-source state modifications
    
    Setting a child-source state to anything but SD_EVENT_OFF currently does
    nothing. The condition logic is flawed. Move the state update *below* the
    test for the previous state.
    
    Fixes a crash if you call:
      sd_event_source_set_enabled(source, SD_EVENT_ON);
      sd_event_source_unref(source);
    on a child-source in its own callback.

diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index f33a9ec..cf2efa6 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -1286,8 +1286,6 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
                         break;
 
                 case SOURCE_CHILD:
-                        s->enabled = m;
-
                         if (s->enabled == SD_EVENT_OFF) {
                                 s->event->n_enabled_child_sources++;
 
@@ -1296,6 +1294,8 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
                                         event_update_signal_fd(s->event);
                                 }
                         }
+
+                        s->enabled = m;
                         break;
 
                 case SOURCE_EXIT:



More information about the systemd-commits mailing list