加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-udev-propagate-error-on-spawning-a-worker.patch 3.09 KB
一键复制 编辑 原始数据 按行查看 历史
From f2a5412bf286cabc047dc96395c2dae978e722b4 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Thu, 17 Jun 2021 15:47:34 +0900
Subject: [PATCH] udev: propagate error on spawning a worker
Reference:https://github.com/systemd/systemd/commit/f2a5412bf286cabc047dc96395c2dae978e722b4
Conflict:NA
---
src/udev/udevd.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 2179825..7f41336 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -720,16 +720,18 @@ static int worker_spawn(Manager *manager, Event *event) {
return 0;
}
-static void event_run(Manager *manager, Event *event) {
+static int event_run(Event *event) {
static bool log_children_max_reached = true;
+ Manager *manager;
Worker *worker;
int r;
- assert(manager);
assert(event);
+ assert(event->manager);
log_device_uevent(event->dev, "Device ready for processing");
+ manager = event->manager;
HASHMAP_FOREACH(worker, manager->workers) {
if (worker->state != WORKER_IDLE)
continue;
@@ -743,29 +745,32 @@ static void event_run(Manager *manager, Event *event) {
continue;
}
worker_attach_event(worker, event);
- return;
+ return 1; /* event is now processing. */
}
if (hashmap_size(manager->workers) >= arg_children_max) {
-
/* Avoid spamming the debug logs if the limit is already reached and
* many events still need to be processed */
if (log_children_max_reached && arg_children_max > 1) {
log_debug("Maximum number (%u) of children reached.", hashmap_size(manager->workers));
log_children_max_reached = false;
}
- return;
+ return 0; /* no free worker */
}
/* 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 */
+ * 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 */
- worker_spawn(manager, event);
+ r = worker_spawn(manager, event);
+ if (r < 0)
+ return r;
+
+ return 1; /* event is now processing. */
}
/* lookup event for identical, parent, child device */
@@ -921,7 +926,9 @@ static int event_queue_start(Manager *manager) {
if (is_device_busy(manager, event) != 0)
continue;
- event_run(manager, event);
+ r = event_run(event);
+ if (r < 0)
+ return r;
}
return 0;
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化