加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-udev-rename-is_device_busy-event_is_blocked.patch 5.27 KB
一键复制 编辑 原始数据 按行查看 历史
From a1fa99d84124cdcd4a306113ebe4febc1251c41c Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Thu, 17 Jun 2021 16:14:01 +0900
Subject: [PATCH] udev: rename is_device_busy() -> event_is_blocked()
Also this rename delaying_seqnum -> blocker_seqnum.
Reference:https://github.com/systemd/systemd/commit/a1fa99d84124cdcd4a306113ebe4febc1251c41c
Conflict:NA
---
src/udev/udevd.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index e99c2c0..20bd556 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -126,7 +126,7 @@ typedef struct Event {
sd_device *dev_kernel; /* clone of originally received device */
uint64_t seqnum;
- uint64_t delaying_seqnum;
+ uint64_t blocker_seqnum;
sd_event_source *timeout_warning_event;
sd_event_source *timeout_event;
@@ -773,8 +773,7 @@ static int event_run(Event *event) {
return 1; /* event is now processing. */
}
-/* lookup event for identical, parent, child device */
-static int is_device_busy(Manager *manager, Event *event) {
+static int event_is_blocked(Event *event) {
const char *subsystem, *devpath, *devpath_old = NULL;
dev_t devnum = makedev(0, 0);
Event *loop_event;
@@ -782,6 +781,8 @@ static int is_device_busy(Manager *manager, Event *event) {
int r, ifindex = 0;
bool is_block;
+ /* lookup event for identical, parent, child device */
+
r = sd_device_get_subsystem(event->dev, &subsystem);
if (r < 0)
return r;
@@ -807,21 +808,21 @@ static int is_device_busy(Manager *manager, Event *event) {
return r;
/* check if queue contains events we depend on */
- LIST_FOREACH(event, loop_event, manager->events) {
+ LIST_FOREACH(event, loop_event, event->manager->events) {
size_t loop_devpath_len, common;
const char *loop_devpath;
/* we already found a later event, earlier cannot block us, no need to check again */
- if (loop_event->seqnum < event->delaying_seqnum)
+ if (loop_event->seqnum < event->blocker_seqnum)
continue;
/* event we checked earlier still exists, no need to check again */
- if (loop_event->seqnum == event->delaying_seqnum)
+ if (loop_event->seqnum == event->blocker_seqnum)
return true;
/* found ourself, no later event can block us */
if (loop_event->seqnum >= event->seqnum)
- break;
+ return false;
/* check major/minor */
if (major(devnum) != 0) {
@@ -833,7 +834,7 @@ static int is_device_busy(Manager *manager, Event *event) {
if (sd_device_get_devnum(loop_event->dev, &d) >= 0 &&
devnum == d && is_block == streq(s, "block"))
- goto set_delaying_seqnum;
+ break;
}
/* check network device ifindex */
@@ -842,7 +843,7 @@ static int is_device_busy(Manager *manager, Event *event) {
if (sd_device_get_ifindex(loop_event->dev, &i) >= 0 &&
ifindex == i)
- goto set_delaying_seqnum;
+ break;
}
if (sd_device_get_devpath(loop_event->dev, &loop_devpath) < 0)
@@ -850,7 +851,7 @@ static int is_device_busy(Manager *manager, Event *event) {
/* check our old name */
if (devpath_old && streq(devpath_old, loop_devpath))
- goto set_delaying_seqnum;
+ break;
loop_devpath_len = strlen(loop_devpath);
@@ -863,24 +864,23 @@ static int is_device_busy(Manager *manager, Event *event) {
/* identical device event found */
if (devpath_len == loop_devpath_len)
- goto set_delaying_seqnum;
+ break;
/* parent device event found */
if (devpath[common] == '/')
- goto set_delaying_seqnum;
+ break;
/* child device event found */
if (loop_devpath[common] == '/')
- goto set_delaying_seqnum;
+ break;
}
- return false;
+ assert(loop_event);
-set_delaying_seqnum:
log_device_debug(event->dev, "SEQNUM=%" PRIu64 " blocked by SEQNUM=%" PRIu64,
event->seqnum, loop_event->seqnum);
- event->delaying_seqnum = loop_event->seqnum;
+ event->blocker_seqnum = loop_event->seqnum;
return true;
}
@@ -923,7 +923,7 @@ static int event_queue_start(Manager *manager) {
continue;
/* do not start event if parent or child event is still running */
- if (is_device_busy(manager, event) != 0)
+ if (event_is_blocked(event) != 0)
continue;
r = event_run(event);
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化