summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-06-02 23:05:40 +0200
committerTom Gundersen <teg@jklm.no>2015-06-03 02:03:15 +0200
commitb7f74dd48f7f3166caf781487c1f5c51f6b70d48 (patch)
treef04e2ef4075b2ed8a3abaa842ee3d1927eb9b6ea
parentf59118ec7911730bb79b273bb4034f5eb4c80868 (diff)
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.
-rw-r--r--src/udev/udevd.c17
1 files changed, 9 insertions, 8 deletions
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;