From b6107f010a1568715a4d4dbb634e01518bd8a336 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 6 Nov 2018 15:58:41 +0900 Subject: [PATCH] udevd: decrease indentation --- src/udev/udevd.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 0aec3acd07..9ab10d9d6f 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -1270,28 +1270,30 @@ static int on_sigchld(sd_event_source *s, const struct signalfd_siginfo *si, voi static int on_post(sd_event_source *s, void *userdata) { Manager *manager = userdata; - int r; assert(manager); - if (LIST_IS_EMPTY(manager->events)) { - /* no pending events */ - if (!hashmap_isempty(manager->workers)) { - /* there are idle workers */ - log_debug("cleanup idle workers"); - manager_kill_workers(manager); - } else { - /* we are idle */ - if (manager->exit) { - r = sd_event_exit(manager->event, 0); - if (r < 0) - return r; - } else if (manager->cgroup) - /* cleanup possible left-over processes in our cgroup */ - cg_kill(SYSTEMD_CGROUP_CONTROLLER, manager->cgroup, SIGKILL, CGROUP_IGNORE_SELF, NULL, NULL, NULL); - } + if (!LIST_IS_EMPTY(manager->events)) + return 1; + + /* There are no pending events. Let's cleanup idle process. */ + + if (!hashmap_isempty(manager->workers)) { + /* There are idle workers */ + log_debug("Cleanup idle workers"); + manager_kill_workers(manager); + return 1; } + /* There are no idle workers. */ + + if (manager->exit) + return sd_event_exit(manager->event, 0); + + if (manager->cgroup) + /* cleanup possible left-over processes in our cgroup */ + (void) cg_kill(SYSTEMD_CGROUP_CONTROLLER, manager->cgroup, SIGKILL, CGROUP_IGNORE_SELF, NULL, NULL, NULL); + return 1; }