summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-09-12 16:45:19 +0200
committerTom Gundersen <teg@jklm.no>2014-09-16 12:12:56 +0200
commit3f56f784b98a4b0ad45409a9a19fd787cd7ae455 (patch)
tree4844d763081c4395350bffab5f0cfee576a5bc8a /src/udev
parent5c67cf2774a8b964f4d7cd92a4c447da81ac6087 (diff)
udevd: initialize epoll_event structs on allocation
Also move the rest of event initialization next to the event loop (no functional change).
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 e90d9dacb0..04014b468a 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1085,7 +1085,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;
@@ -1221,6 +1225,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");
@@ -1247,32 +1277,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);
@@ -1289,24 +1297,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];