summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-09-12 16:45:19 +0200
committerAnthony G. Basile <blueness@gentoo.org>2014-09-17 19:58:09 -0400
commitaf353f0f00f9d1bbbcb18baadda2375457d2ae34 (patch)
tree65c06ee7fb8a37eece4dfb402c9b96c562874c28 /src/udev
parentb2399d9b7222abe7db8ab4bc16e0efe3ccae4c42 (diff)
udevd: initialize epoll_event structs on allocation
Also move the rest of event initialization next to the event loop (no functional change). Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udevd.c72
1 files changed, 31 insertions, 41 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 408497bf26..b5350f7a42 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1112,7 +1112,11 @@ int main(int argc, char *argv[]) {
int fd_ctrl = -1;
int fd_netlink = -1;
int fd_worker = -1;
- struct epoll_event ep_ctrl, ep_inotify, ep_signal, ep_netlink, ep_worker;
+ struct epoll_event ep_ctrl = { .events = EPOLLIN };
+ struct epoll_event ep_inotify = { .events = EPOLLIN };
+ struct epoll_event ep_signal = { .events = EPOLLIN };
+ struct epoll_event ep_netlink = { .events = EPOLLIN };
+ struct epoll_event ep_worker = { .events = EPOLLIN };
struct udev_ctrl_connection *ctrl_conn = NULL;
int rc = 1, r;
@@ -1229,6 +1233,32 @@ int main(int argc, char *argv[]) {
log_info("starting version " VERSION "\n");
+ udev_builtin_init(udev);
+
+ rules = udev_rules_new(udev, arg_resolve_names);
+ if (rules == NULL) {
+ log_error("error reading rules");
+ goto exit;
+ }
+
+ rc = udev_rules_apply_static_dev_perms(rules);
+ if (rc < 0)
+ log_error("failed to apply permissions on static device nodes - %s", strerror(-rc));
+
+ if (arg_children_max <= 0) {
+ cpu_set_t cpu_set;
+
+ arg_children_max = 8;
+
+ if (sched_getaffinity(0, sizeof (cpu_set), &cpu_set) == 0) {
+ arg_children_max += CPU_COUNT(&cpu_set) * 2;
+ }
+ }
+ log_debug("set children_max to %u", arg_children_max);
+
+ udev_list_node_init(&event_list);
+ udev_list_node_init(&worker_list);
+
fd_inotify = udev_watch_init(udev);
if (fd_inotify < 0) {
log_error("error initializing inotify");
@@ -1267,32 +1297,10 @@ int main(int argc, char *argv[]) {
}
fd_worker = worker_watch[READ_END];
- udev_builtin_init(udev);
-
- rules = udev_rules_new(udev, arg_resolve_names);
- if (rules == NULL) {
- log_error("error reading rules");
- goto exit;
- }
-
- memzero(&ep_ctrl, sizeof(struct epoll_event));
- ep_ctrl.events = EPOLLIN;
ep_ctrl.data.fd = fd_ctrl;
-
- memzero(&ep_inotify, sizeof(struct epoll_event));
- ep_inotify.events = EPOLLIN;
ep_inotify.data.fd = fd_inotify;
-
- memzero(&ep_signal, sizeof(struct epoll_event));
- ep_signal.events = EPOLLIN;
ep_signal.data.fd = fd_signal;
-
- memzero(&ep_netlink, sizeof(struct epoll_event));
- ep_netlink.events = EPOLLIN;
ep_netlink.data.fd = fd_netlink;
-
- memzero(&ep_worker, sizeof(struct epoll_event));
- ep_worker.events = EPOLLIN;
ep_worker.data.fd = fd_worker;
fd_ep = epoll_create1(EPOLL_CLOEXEC);
@@ -1309,24 +1317,6 @@ int main(int argc, char *argv[]) {
goto exit;
}
- if (arg_children_max <= 0) {
- cpu_set_t cpu_set;
-
- arg_children_max = 8;
-
- if (sched_getaffinity(0, sizeof (cpu_set), &cpu_set) == 0) {
- arg_children_max += CPU_COUNT(&cpu_set) * 2;
- }
- }
- log_debug("set children_max to %u", arg_children_max);
-
- rc = udev_rules_apply_static_dev_perms(rules);
- if (rc < 0)
- log_error("failed to apply permissions on static device nodes - %s", strerror(-rc));
-
- udev_list_node_init(&event_list);
- udev_list_node_init(&worker_list);
-
for (;;) {
static usec_t last_usec;
struct epoll_event ev[8];