diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-11-10 12:57:34 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-11-10 14:19:20 +0100 |
commit | ac9f2640cb9c107b43f47bba7e068d3b92b5337b (patch) | |
tree | 5d6df67692cc0771d75396cdd6ae43490c56b3fd /src/libsystemd/sd-event/sd-event.c | |
parent | sd-event: update state at the end in event_source_enable (diff) | |
download | systemd-ac9f2640cb9c107b43f47bba7e068d3b92b5337b.tar.xz systemd-ac9f2640cb9c107b43f47bba7e068d3b92b5337b.zip |
sd-event: increase n_enabled_child_sources just once
Neither source_child_pidfd_register() nor event_make_signal_data() look at
n_enabled_child_sources.
Diffstat (limited to '')
-rw-r--r-- | src/libsystemd/sd-event/sd-event.c | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 5f66c379b5..0d3d81959c 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -1340,31 +1340,25 @@ _public_ int sd_event_add_child( if (r < 0) return r; - e->n_enabled_child_sources++; - if (EVENT_SOURCE_WATCH_PIDFD(s)) { /* We have a pidfd and we only want to watch for exit */ - r = source_child_pidfd_register(s, s->enabled); - if (r < 0) { - e->n_enabled_child_sources--; + if (r < 0) return r; - } + } else { /* We have no pidfd or we shall wait for some other event than WEXITED */ - r = event_make_signal_data(e, SIGCHLD, NULL); - if (r < 0) { - e->n_enabled_child_sources--; + if (r < 0) return r; - } e->need_process_child = true; } + e->n_enabled_child_sources++; + if (ret) *ret = s; - TAKE_PTR(s); return 0; } @@ -1429,31 +1423,24 @@ _public_ int sd_event_add_child_pidfd( if (r < 0) return r; - e->n_enabled_child_sources++; - if (EVENT_SOURCE_WATCH_PIDFD(s)) { /* We only want to watch for WEXITED */ - r = source_child_pidfd_register(s, s->enabled); - if (r < 0) { - e->n_enabled_child_sources--; + if (r < 0) return r; - } } else { /* We shall wait for some other event than WEXITED */ - r = event_make_signal_data(e, SIGCHLD, NULL); - if (r < 0) { - e->n_enabled_child_sources--; + if (r < 0) return r; - } e->need_process_child = true; } + e->n_enabled_child_sources++; + if (ret) *ret = s; - TAKE_PTR(s); return 0; } @@ -2342,27 +2329,24 @@ static int event_source_enable(sd_event_source *s, int enable) { break; case SOURCE_CHILD: - s->event->n_enabled_child_sources++; - if (EVENT_SOURCE_WATCH_PIDFD(s)) { /* yes, we have pidfd */ r = source_child_pidfd_register(s, enable); - if (r < 0) { - s->event->n_enabled_child_sources--; + if (r < 0) return r; - } } else { /* no pidfd, or something other to watch for than WEXITED */ r = event_make_signal_data(s->event, SIGCHLD, NULL); if (r < 0) { - s->event->n_enabled_child_sources--; event_gc_signal_data(s->event, &s->priority, SIGCHLD); return r; } } + s->event->n_enabled_child_sources++; + break; case SOURCE_TIME_REALTIME: |