From fa28bc2df724e4aff46d19cb7aa732cc64c71061 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 18 Dec 2013 03:46:53 +0100 Subject: [PATCH] core: priorize notification fd processing over notification fd process via sd-event's logic --- src/core/manager.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/manager.c b/src/core/manager.c index 6a755975f..634b1414f 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -135,6 +135,12 @@ static int manager_setup_notify(Manager *m) { return -errno; } + /* Process signals a bit earlier than SIGCHLD, so that we can + * still identify to which service an exit message belongs */ + r = sd_event_source_set_priority(m->notify_event_source, -7); + if (r < 0) + return r; + sa.un.sun_path[0] = '@'; m->notify_socket = strdup(sa.un.sun_path); if (!m->notify_socket) @@ -367,7 +373,10 @@ static int manager_setup_signals(Manager *m) { if (r < 0) return r; - /* Process signals a bit earlier than the rest of things */ + /* Process signals a bit earlier than the rest of things, but + * later that notify_fd processing, so that the notify + * processing can still figure out to which process/service a + * message belongs, before we reap the process. */ r = sd_event_source_set_priority(m->signal_event_source, -5); if (r < 0) return r; @@ -1331,7 +1340,6 @@ static int manager_dispatch_sigchld(Manager *m) { for (;;) { siginfo_t si = {}; Unit *u; - int r; /* First we call waitd() for a PID and do not reap the * zombie. That way we can still access /proc/$PID for @@ -1357,14 +1365,6 @@ static int manager_dispatch_sigchld(Manager *m) { log_debug("Got SIGCHLD for process %lu (%s)", (unsigned long) si.si_pid, strna(name)); } - /* Let's flush any message the dying child might still - * have queued for us. This ensures that the process - * still exists in /proc so that we can figure out - * which cgroup and hence unit it belongs to. */ - r = manager_dispatch_notify_fd(m->notify_event_source, m->notify_fd, EPOLLIN, m); - if (r < 0) - return r; - /* And now figure out the unit this belongs to */ u = hashmap_get(m->watch_pids, LONG_TO_PTR(si.si_pid)); if (!u) -- 2.30.2