From b7f74dd48f7f3166caf781487c1f5c51f6b70d48 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 2 Jun 2015 23:05:40 +0200 Subject: udevd: manager - split listen_fds() out of manager_new() This will allow us in a follow-up commit to listen to fds before forking and still allocate the manager only after the fork. --- src/udev/udevd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 259767b3f6..a6cddf6e5a 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -1490,9 +1490,8 @@ static int parse_argv(int argc, char *argv[]) { return 1; } -static int manager_new(Manager **ret, const char *cgroup) { +static int manager_new(Manager **ret, int fd_ctrl, int fd_uevent, const char *cgroup) { _cleanup_(manager_freep) Manager *manager = NULL; - int r, fd_ctrl, fd_uevent; assert(ret); @@ -1519,10 +1518,6 @@ static int manager_new(Manager **ret, const char *cgroup) { manager->cgroup = cgroup; - r = listen_fds(&fd_ctrl, &fd_uevent); - if (r < 0) - return log_error_errno(r, "could not listen on fds: %m"); - manager->ctrl = udev_ctrl_new_from_fd(manager->udev, fd_ctrl); if (!manager->ctrl) return log_error_errno(EINVAL, "error taking over udev control socket"); @@ -1620,7 +1615,7 @@ static int manager_listen(Manager *manager) { int main(int argc, char *argv[]) { _cleanup_(manager_freep) Manager *manager = NULL; _cleanup_free_ char *cgroup = NULL; - int r; + int r, fd_ctrl, fd_uevent; log_set_target(LOG_TARGET_AUTO); log_parse_environment(); @@ -1686,7 +1681,13 @@ int main(int argc, char *argv[]) { log_warning_errno(r, "failed to get cgroup: %m"); } - r = manager_new(&manager, cgroup); + r = listen_fds(&fd_ctrl, &fd_uevent); + if (r < 0) { + r = log_error_errno(r, "could not listen on fds: %m"); + goto exit; + } + + r = manager_new(&manager, fd_ctrl, fd_uevent, cgroup); if (r < 0) goto exit; -- cgit v1.2.3-54-g00ecf