udev: try to reload selinux label database less frequently

Previously, `event_run()` was called repeatedly in one `event_queue_start()`
invocation. Hence, the SELinux label database is reloaded many times needlessly.
Other settings, e.g. udev rules or hwdata, are tried to be reloaded in the
beginning of `event_queue_start()`. Let's also do so for the SELinux database.
This commit is contained in:
Yu Watanabe
2022-03-24 16:20:42 +01:00
committed by Lennart Poettering
parent 2d40f02ee4
commit c02fb80479
+4 -4
View File
@@ -760,10 +760,6 @@ static int event_run(Event *event) {
/* Re-enable the debug message for the next batch of events */
log_children_max_reached = true;
/* fork with up-to-date SELinux label database, so the child inherits the up-to-date db
* and, until the next SELinux policy changes, we safe further reloads in future children */
mac_selinux_maybe_reload();
/* start new worker and pass initial device */
r = worker_spawn(manager, event);
if (r < 0)
@@ -945,6 +941,10 @@ static int event_queue_start(Manager *manager) {
return log_warning_errno(r, "Failed to read udev rules: %m");
}
/* fork with up-to-date SELinux label database, so the child inherits the up-to-date db
* and, until the next SELinux policy changes, we safe further reloads in future children */
mac_selinux_maybe_reload();
LIST_FOREACH(event, event, manager->events) {
if (event->state != EVENT_QUEUED)
continue;