代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/systemd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From a3d2f4261ef9a953904e3e21abafba0dad7daa77 Mon Sep 17 00:00:00 2001
From: gaoyi <gaoyi15@huawei.com>
Date: Mon, 28 Sep 2020 22:36:37 +0800
Subject: [PATCH] Retry to handle the uevent when worker is terminated abnormal
When processing uevent events fails, retry it.
---
src/udev/udev-manager.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/udev/udev-manager.c b/src/udev/udev-manager.c
index 8077e51..88023c7 100644
--- a/src/udev/udev-manager.c
+++ b/src/udev/udev-manager.c
@@ -36,6 +36,7 @@
#include "udev-worker.h"
#define WORKER_NUM_MAX UINT64_C(2048)
+#define UEVENT_MAX_RETRY_TIMES 3
#define EVENT_RETRY_INTERVAL_USEC (200 * USEC_PER_MSEC)
#define EVENT_RETRY_TIMEOUT_USEC (3 * USEC_PER_MINUTE)
@@ -50,6 +51,7 @@ typedef struct Event {
Manager *manager;
Worker *worker;
EventState state;
+ int retry;
sd_device *dev;
@@ -89,6 +91,32 @@ typedef struct Worker {
Event *event;
} Worker;
+static bool event_retry(Event *event) {
+ if (!event)
+ return false;
+
+ assert(event->manager);
+
+ if (--event->retry < 0) {
+ log_device_error(event->dev, "Retry failed.");
+ return false;
+ }
+
+ log_device_info(event->dev, "Retry %d times.", UEVENT_MAX_RETRY_TIMES - event->retry);
+
+ event->timeout_warning_event = sd_event_source_unref(event->timeout_warning_event);
+ event->timeout_event = sd_event_source_unref(event->timeout_event);
+
+ if (event->worker) {
+ event->worker->event = NULL;
+ event->worker = NULL;
+ }
+
+ event->state = EVENT_QUEUED;
+
+ return true;
+}
+
static Event *event_free(Event *event) {
if (!event)
return NULL;
@@ -735,6 +763,7 @@ static int event_queue_insert(Manager *manager, sd_device *dev) {
.devpath_old = devpath_old,
.devnode = devnode,
.state = EVENT_QUEUED,
+ .retry = UEVENT_MAX_RETRY_TIMES,
};
if (!manager->events) {
@@ -1126,8 +1155,10 @@ static int on_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
device_delete_db(dev);
device_tag_index(dev, NULL, false);
- /* Forward kernel event to libudev listeners */
- udev_broadcast_result(manager->monitor, dev, result);
+ if (event_retry(worker->event) == false) {
+ /* Forward kernel event to libudev listeners */
+ udev_broadcast_result(manager->monitor, dev, result);
+ }
}
worker_free(worker);
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。