From e04dc842da1b90bc688c77234068516eb2d18fd9 Mon Sep 17 00:00:00 2001 From: gongheng Date: Mon, 16 Nov 2026 09:19:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96USB=E7=83=AD=E6=8F=92?= =?UTF-8?q?=E6=8B=94=E5=A4=84=E7=90=86=E9=81=BF=E5=85=8D=E9=9F=B3=E9=A2=91?= =?UTF-8?q?=E5=8D=A1=E9=A1=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 简化DetectThread,移除sysfs轮询逻辑,直接转发usbChanged信号; 2. 为hwinfo、lshw、lspci、smartctl、bluetoothctl等外部命令添加超时保护; 3. 移除updateHotplugInfo独立路径,统一使用updateInfo并按命令设置超时; 4. ThreadPoolTask的runCmd增加timeoutMs参数,防止命令无限阻塞; 5. 更新LoadInfoThread和MainWindow适配新的超时机制; 6. 更新DBusInterface接口适配; ===================================== 1. simplified DetectThread by removing sysfs polling logic and forwarding usbChanged signal directly; 2. added timeout protection for external commands (hwinfo, lshw, lspci, smartctl, bluetoothctl); 3. removed separate updateHotplugInfo path, unified into updateInfo with per-command timeouts; 4. added timeoutMs parameter to ThreadPoolTask::runCmd to prevent indefinite blocking; 5. updated LoadInfoThread and MainWindow to adapt to the new timeout mechanism; 6. updated DBusInterface to match the new interface; Log: 通过为所有外部命令添加超时保护并简化USB热插拔处理流程,避免设备管理器在USB插拔时长时间占用CPU导致音频卡顿 Task: https://pms.uniontech.com/task-view-398371.html --- .../src/hotplug/detectthread.cpp | 63 +------- .../src/hotplug/detectthread.h | 28 +--- .../src/hotplug/monitorusb.cpp | 10 +- .../src/loadinfo/threadpool.cpp | 43 +++--- .../src/loadinfo/threadpool.h | 22 +-- .../src/loadinfo/threadpooltask.cpp | 43 ++++-- .../src/loadinfo/threadpooltask.h | 10 +- .../deepin-deviceinfo/src/mainjob.cpp | 69 ++++++--- .../deepin-deviceinfo/src/mainjob.h | 3 +- .../src/GenerateDevice/DBusInterface.cpp | 22 ++- .../src/GenerateDevice/DBusInterface.h | 5 +- .../src/GenerateDevice/LoadInfoThread.cpp | 141 +++++++++++------- .../src/GenerateDevice/LoadInfoThread.h | 18 ++- deepin-devicemanager/src/Page/MainWindow.cpp | 81 +++++----- deepin-devicemanager/src/Page/MainWindow.h | 8 +- 15 files changed, 292 insertions(+), 274 deletions(-) diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/detectthread.cpp b/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/detectthread.cpp index e5649a7dd..142fc8471 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/detectthread.cpp +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/detectthread.cpp @@ -4,25 +4,12 @@ #include "detectthread.h" #include "monitorusb.h" -#include "DDLog.h" - -#include -#include -#include - -using namespace DDLog; - -// 内核把 USB 设备信息填充完成的最长等待时间。 -// 纯 sysfs 探测,等待期间几乎不消耗 CPU。 -static constexpr int kUsbSettleMaxMs = 1000; -static constexpr int kUsbSettleStepMs = 100; DetectThread::DetectThread(QObject *parent) : QThread(parent) , mp_MonitorUsb(new MonitorUsb()) { - // 连接槽函数 - connect(mp_MonitorUsb, SIGNAL(usbChanged()), this, SLOT(slotUsbChanged()), Qt::QueuedConnection); + connect(mp_MonitorUsb, &MonitorUsb::usbChanged, this, &DetectThread::usbChanged, Qt::QueuedConnection); } void DetectThread::run() @@ -39,51 +26,3 @@ void DetectThread::setWorkingFlag(bool flag) start(); } } - -void DetectThread::slotUsbChanged() -{ - // 当监听到新的usb时,内核需要加载usb信息,而上层应用需要在内核处理之后获取信息。 - // 这里只做纯 sysfs 的就绪探测,不再 spawn hwinfo: - // 原实现每秒执行一次 `hwinfo --usb --keyboard --mouse`(单次 300~400ms) - // 直到设备信息变化,最多 10 秒即 11 个进程;在 USB 反复上报事件但设备列表 - // 实际未变时会跑满 10 秒,持续占满一个 CPU 核心,播放中的音频因此丢帧。 - qint64 begin = QDateTime::currentMSecsSinceEpoch(); - const bool ready = waitKernelUsbReady(kUsbSettleMaxMs); - qCInfo(appLog) << " usb settle time:" << QDateTime::currentMSecsSinceEpoch() - begin - << " ready:" << ready; - emit usbChanged(); -} - -bool DetectThread::waitKernelUsbReady(int maxWaitMs) -{ - const qint64 begin = QDateTime::currentMSecsSinceEpoch(); - while (true) { - bool ready = true; - - QDir dir("/sys/bus/usb/devices"); - const QFileInfoList entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); - for (const QFileInfo &entry : entries) { - const QString path = entry.absoluteFilePath(); - if (entry.fileName().contains(':')) { - // usb_interface:还没有 driver 符号链接说明驱动仍在 probe - if (!QFileInfo::exists(path + "/driver")) { - ready = false; - break; - } - } else if (QFileInfo::exists(path + "/idVendor")) { - // usb_device:已枚举 - continue; - } else { - ready = false; - break; - } - } - - if (ready) - return true; - if (QDateTime::currentMSecsSinceEpoch() - begin >= maxWaitMs) - return false; - - msleep(kUsbSettleStepMs); - } -} diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/detectthread.h b/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/detectthread.h index 4b1dc625f..6d69d787d 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/detectthread.h +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/detectthread.h @@ -6,12 +6,13 @@ #define DETECTTHREAD_H #include -#include class MonitorUsb; /** * @brief The DetectThread class + * + * 只负责运行 udev 监控线程并转发 usbChanged 通知。 */ class DetectThread : public QThread { @@ -31,33 +32,10 @@ class DetectThread : public QThread signals: /** - * @brief usbChanged + * @brief usbChanged usb/蓝牙设备发生变化 */ void usbChanged(); -private slots: - /** - * @brief slotUsbChanged usb发生变化时的曹函数处理 - */ - void slotUsbChanged(); - -private: - /** - * @brief waitKernelUsbReady 等待内核把 USB 设备信息填充完成 - * - * 原实现通过反复执行 `hwinfo --usb --keyboard --mouse`(单次 300~400ms) - * 并比对输出来判断"插拔是否处理完",最多循环 10 秒,即最多 spawn 11 个 - * hwinfo 进程。在"USB 反复上报事件、但设备列表实际没变"的场景下会跑满 - * 10 秒,持续占满一个 CPU 核心,正在播放的音频因此丢帧(表现为"滋滋"声)。 - * - * 这里改为纯 sysfs 探测:usb_device 都已有 idVendor、且 usb_interface 都已 - * 绑定驱动,说明内核已处理完毕。全程只读文件,不产生任何子进程。 - * - * @param maxWaitMs 最长等待毫秒数 - * @return true 表示已经就绪 - */ - bool waitKernelUsbReady(int maxWaitMs); - private: MonitorUsb *mp_MonitorUsb; // #include #include +#include // 一批 udev 事件平息多久之后才执行合并的 hwinfo --usb static constexpr qint64 kEventSettleMs = 500; +// 单次 hwinfo --usb 的等待上限。 +static constexpr int kUsbInfoTimeoutMs = 8000; MonitorUsb::MonitorUsb() : m_workingFlag(true) @@ -106,7 +109,12 @@ void MonitorUsb::applyUsbControl() QProcess process; process.start("hwinfo --usb"); - process.waitForFinished(-1); + if (!process.waitForFinished(kUsbInfoTimeoutMs)) { + process.kill(); + process.waitForFinished(1000); + qWarning() << "hwinfo --usb timeout, skip usb control/wakeup update"; + return; + } const QString info = process.readAllStandardOutput(); if (needControl) diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpool.cpp b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpool.cpp index 1ddbf70ed..2c0b1ad33 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpool.cpp +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpool.cpp @@ -10,6 +10,12 @@ #include #include +static constexpr int kFastCmdTimeoutMs = 5000; // 毫秒级完成的命令 +static constexpr int kLshwTimeoutMs = 10000; // lshw 要遍历整机设备树 +static constexpr int kHwinfoTimeoutMs = 15000; // 9 类探测,最容易被硬件拖慢 +static constexpr int kHwinfoMonitorTimeoutMs = 10000; +static constexpr int kBluetoothCtlTimeoutMs = 500; // bluetoothctl 可能连不上守护进程 + ThreadPool::ThreadPool(QObject *parent) : QThreadPool(parent) { @@ -31,12 +37,6 @@ void ThreadPool::updateDeviceInfo() updateInfo(m_ListUpdate); } -void ThreadPool::updateHotplugInfo() -{ - // 只刷新与 USB 插拔相关、开销可控的信息 - updateInfo(m_ListHotplug); -} - void ThreadPool::updateInfo(const QList &cmds) { for (const Cmd &cmd : cmds) { @@ -44,12 +44,6 @@ void ThreadPool::updateInfo(const QList &cmds) task->setAutoDelete(true); start(task); } - - // 等待所有任务执行完毕,最多 10 秒。 - // 原实现是 while (true) + activeThreadCount() 的忙等自旋,不 sleep, - // 会白占一个 CPU 核心最多 10 秒;音频等实时线程正好被它挤掉时间片。 - // QThreadPool::waitForDone() 内部用条件变量等待,不消耗 CPU。 - waitForDone(10000); } void ThreadPool::initCmd() @@ -59,6 +53,7 @@ void ThreadPool::initCmd() cmdLshw.cmd = QString("%1 %2%3").arg("lshw > ").arg(PATH).arg("lshw.txt"); cmdLshw.file = "lshw.txt"; cmdLshw.canNotReplace = false; + cmdLshw.waitingTime = kLshwTimeoutMs; m_ListCmd.append(cmdLshw); m_ListUpdate.append(cmdLshw); @@ -130,6 +125,7 @@ void ThreadPool::initCmd() cmdUpower.cmd = QString("%1 %2%3").arg("upower --dump > ").arg(PATH).arg("upower_dump.txt"); cmdUpower.file = "upower_dump.txt"; cmdUpower.canNotReplace = true; + cmdUpower.waitingTime = kFastCmdTimeoutMs; m_ListCmd.append(cmdUpower); m_ListUpdate.append(cmdUpower); @@ -146,6 +142,7 @@ void ThreadPool::initCmd() cmdLsblk.cmd = QString("%1 %2%3").arg("lsblk -d -o name,rota > ").arg(PATH).arg("lsblk_d.txt"); cmdLsblk.file = "lsblk_d.txt"; cmdLsblk.canNotReplace = false; + cmdLsblk.waitingTime = kFastCmdTimeoutMs; m_ListCmd.append(cmdLsblk); m_ListUpdate.append(cmdLsblk); @@ -154,6 +151,7 @@ void ThreadPool::initCmd() cmdLssg.cmd = QString("%1 %2%3").arg("ls /dev/sg* > ").arg(PATH).arg("ls_sg.txt"); cmdLssg.file = "ls_sg.txt"; cmdLssg.canNotReplace = false; + cmdLssg.waitingTime = kFastCmdTimeoutMs; m_ListCmd.append(cmdLssg); m_ListUpdate.append(cmdLssg); @@ -162,6 +160,7 @@ void ThreadPool::initCmd() cmdLspci.cmd = QString("%1 %2%3").arg("lspci > ").arg(PATH).arg("lspci.txt"); cmdLspci.file = "lspci.txt"; cmdLspci.canNotReplace = false; + cmdLspci.waitingTime = kFastCmdTimeoutMs; m_ListCmd.append(cmdLspci); m_ListUpdate.append(cmdLspci); @@ -170,6 +169,7 @@ void ThreadPool::initCmd() cmdLpstate.cmd = QString("%1 %2%3").arg("lpstat -a > ").arg(PATH).arg("lpstat.txt"); cmdLpstate.file = "lpstat.txt"; cmdLpstate.canNotReplace = false; + cmdLpstate.waitingTime = kFastCmdTimeoutMs; m_ListCmd.append(cmdLpstate); m_ListUpdate.append(cmdLpstate); @@ -178,6 +178,7 @@ void ThreadPool::initCmd() cmdDmesg.cmd = QString("%1 %2%3").arg("dmesg > ").arg(PATH).arg("dmesg.txt"); cmdDmesg.file = "dmesg.txt"; cmdDmesg.canNotReplace = true; + cmdDmesg.waitingTime = kFastCmdTimeoutMs; m_ListCmd.append(cmdDmesg); m_ListUpdate.append(cmdDmesg); @@ -186,6 +187,7 @@ void ThreadPool::initCmd() cmdHciconfig.cmd = QString("%1 %2%3").arg("hciconfig -a > ").arg(PATH).arg("hciconfig.txt"); cmdHciconfig.file = "hciconfig.txt"; cmdHciconfig.canNotReplace = false; + cmdHciconfig.waitingTime = kFastCmdTimeoutMs; m_ListCmd.append(cmdHciconfig); m_ListUpdate.append(cmdHciconfig); @@ -194,7 +196,7 @@ void ThreadPool::initCmd() cmdBluetooth.cmd = QString("%1 %2%3").arg("bluetoothctl paired-devices > ").arg(PATH).arg("bt_device.txt"); cmdBluetooth.file = "bt_device.txt"; cmdBluetooth.canNotReplace = false; - cmdBluetooth.waitingTime = 500; + cmdBluetooth.waitingTime = kBluetoothCtlTimeoutMs; m_ListCmd.append(cmdBluetooth); m_ListUpdate.append(cmdBluetooth); @@ -209,6 +211,7 @@ void ThreadPool::initCmd() cmdHwinfo.cmd = QString("%1 %2%3").arg("hwinfo --sound --netcard --keyboard --cdrom --disk --display --mouse --usb --fingerprint > ").arg(PATH).arg("hwinfo.txt"); cmdHwinfo.file = "hwinfo.txt"; cmdHwinfo.canNotReplace = false; + cmdHwinfo.waitingTime = kHwinfoTimeoutMs; m_ListCmd.append(cmdHwinfo); m_ListUpdate.append(cmdHwinfo); @@ -216,19 +219,7 @@ void ThreadPool::initCmd() cmdHwinfoMonitor.cmd = QString("%1 %2%3").arg("hwinfo --monitor > ").arg(PATH).arg("hwinfo_monitor.txt"); cmdHwinfoMonitor.file = "hwinfo_monitor.txt"; cmdHwinfoMonitor.canNotReplace = false; + cmdHwinfoMonitor.waitingTime = kHwinfoMonitorTimeoutMs; m_ListCmd.append(cmdHwinfoMonitor); m_ListUpdate.append(cmdHwinfoMonitor); - - // --------------------------------------------------------------------- - // 热插拔(USB)刷新列表 - // - // 一次插拔只需要更新"会变"的信息。lshw / upower / lscpu / lspci / - // lpstat / bluetoothctl / hwinfo --framebuffer 与插拔无关,却要跑数百 - // 毫秒到数秒,并发执行时会把 CPU 占满,正在播放的音频因此丢帧(滋滋声)。 - // 未列入的命令不执行,其缓存保持上一次的值,不会丢失数据。 - // --------------------------------------------------------------------- - m_ListHotplug.append(cmdLsblk); // 新增/移除磁盘 - m_ListHotplug.append(cmdLssg); // 新增/移除 SCSI 通用设备 - m_ListHotplug.append(cmdHciconfig); // 蓝牙适配器状态 - m_ListHotplug.append(cmdHwinfo); // 含 --sound:声卡拓扑也可能变化 } diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpool.h b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpool.h index c7145721f..117e3cd86 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpool.h +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpool.h @@ -14,13 +14,15 @@ * @brief The Cmd struct */ struct Cmd { - Cmd(): cmd(""), file(""), canNotReplace(false), waitingTime(-1) + // waitingTime 不能默认 -1(QProcess 永久等待):单条命令卡住会把整批刷新拖死。 + // 实测常规命令均在毫秒级,5s 已足够宽松;慢命令在 initCmd() 里单独放大。 + Cmd(): cmd(""), file(""), canNotReplace(false), waitingTime(5000) {} QString cmd; // &cmds); @@ -67,7 +62,6 @@ class ThreadPool : public QThreadPool private: QList m_ListCmd; // all cmd QList m_ListUpdate; // update cmd - QList m_ListHotplug; // hotplug(usb) cmd }; #endif // THREADPOOL_H diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpooltask.cpp b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpooltask.cpp index 34f80dac0..8f1a3b535 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpooltask.cpp +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpooltask.cpp @@ -14,6 +14,10 @@ using namespace DDLog; #include #include +static constexpr int kFastCmdTimeoutMs = 5000; // ls / cat 之类的辅助命令 +static constexpr int kLspciTimeoutMs = 5000; // lspci -v -s +static constexpr int kSmartctlTimeoutMs = 8000; // smartctl --all,慢盘/USB 桥接最慢 + ThreadPoolTask::ThreadPoolTask(QString cmd, QString file, bool replace, int waiting, QObject *parent) : QObject(parent), m_Cmd(cmd), @@ -34,7 +38,7 @@ void ThreadPoolTask::run() runCmdToCache(m_Cmd); } -void ThreadPoolTask::runCmd(const QString &cmd, QString &info) +void ThreadPoolTask::runCmd(const QString &cmd, QString &info, int timeoutMs) { QString cmdExec = cmd.left(cmd.indexOf('>')).trimmed(); QString cmdStr = cmdExec.split(' ').first().trimmed(); @@ -47,13 +51,13 @@ void ThreadPoolTask::runCmd(const QString &cmd, QString &info) // 处理包含*的命令参数 if (cmd.startsWith("ls /dev/sg*")) { - info = runAsteriskCmd(cmdStr, args.first().trimmed()); + info = runAsteriskCmd(cmdStr, args.first().trimmed(), kFastCmdTimeoutMs); return; } else if (cmdExec.startsWith("cat /boot/config*")) { QString filter = cmdExec.split('|').last().split(' ').last().replace('\'', ""); if (filter.isEmpty()) return; - QString outPut = runAsteriskCmd("ls", "/boot/config*"); + QString outPut = runAsteriskCmd("ls", "/boot/config*", kFastCmdTimeoutMs); if (outPut.isEmpty()) return; QStringList paths = outPut.split('\n'); @@ -63,7 +67,7 @@ void ThreadPoolTask::runCmd(const QString &cmd, QString &info) continue; QProcess proc; proc.start("cat", QStringList() << path); - proc.waitForFinished(); + proc.waitForFinished(kFastCmdTimeoutMs); QString info1; if (proc.exitStatus() == QProcess::NormalExit && proc.exitCode() == 0) info1 = proc.readAllStandardOutput(); @@ -84,13 +88,20 @@ void ThreadPoolTask::runCmd(const QString &cmd, QString &info) QProcess process; process.start(cmdStr, args); - process.waitForFinished(m_Waiting); + const int waitMs = timeoutMs > 0 ? timeoutMs : m_Waiting; + if (!process.waitForFinished(waitMs)) { + process.kill(); + process.waitForFinished(1000); + qCWarning(appLog) << "command timeout after" << waitMs << "ms, discard output:" << cmd; + info.clear(); + return; + } info = process.readAllStandardOutput(); //qCInfo(deviceInfoLog) << "runcmdExec:" << cmdExec << "args:" << args << "outPut:" << info; } -QString ThreadPoolTask::runAsteriskCmd(const QString &cmd, const QString &arg) +QString ThreadPoolTask::runAsteriskCmd(const QString &cmd, const QString &arg, int timeoutMs) { QString info = ""; if (cmd.isEmpty()) @@ -109,7 +120,13 @@ QString ThreadPoolTask::runAsteriskCmd(const QString &cmd, const QString &arg) QProcess process; process.start(cmd, args); - process.waitForFinished(-1); + // 不能永久等待:这里同样受总刷新预算约束。 + if (!process.waitForFinished(timeoutMs > 0 ? timeoutMs : m_Waiting)) { + process.kill(); + process.waitForFinished(1000); + qCWarning(appLog) << "command timeout:" << cmd << path; + return info; + } QString outPut = process.readAllStandardOutput(); QStringList outPutLines = outPut.trimmed().split('\n'); @@ -193,11 +210,13 @@ void ThreadPoolTask::loadSmartCtlInfoToCache(const QString &info) QString smartCmd = QString("smartctl --all /dev/%1").arg(words[0].trimmed()); QString sInfo; - runCmd(smartCmd, sInfo); + // 每个盘单独限时:机械盘刚唤醒、USB 桥接的盘响应很慢,个别盘甚至不响应。 + // 不能沿用 lsblk 任务的 waitingTime,否则一块坏盘就能拖死整批刷新。 + runCmd(smartCmd, sInfo, kSmartctlTimeoutMs); // 在使用smartctl的时候会出现对 /dev/sda 出现判断错误的情况,此时可以对/dev/sda1进行处理 if (sInfo.contains("Read Device Identity failed:")) { smartCmd = smartCmd + "1"; - runCmd(smartCmd, sInfo); + runCmd(smartCmd, sInfo, kSmartctlTimeoutMs); } DeviceInfoManager::getInstance()->addInfo(QString("smartctl_%1").arg(words[0].trimmed()), sInfo); } @@ -232,7 +251,7 @@ void ThreadPoolTask::loadSgSmartCtlInfoToCache(const QString &info) QString smartCmd = QString("smartctl --all /dev/%1").arg(words[2].trimmed()); QString sInfo; - runCmd(smartCmd, sInfo); + runCmd(smartCmd, sInfo, kSmartctlTimeoutMs); DeviceInfoManager::getInstance()->addInfo(QString("smartctl_%1").arg(words[2]), sInfo); } } @@ -248,7 +267,7 @@ void ThreadPoolTask::loadLspciVSInfoToCache(const QString &info) if (words[1] == QString("ISA")) { QString cmd = QString("lspci -v -s %1").arg(words[0].trimmed()); // > /tmp/device-info/lspci_vs.txt QString sInfo; - runCmd(cmd, sInfo); + runCmd(cmd, sInfo, kLspciTimeoutMs); DeviceInfoManager::getInstance()->addInfo("lspci_vs", sInfo); break; } @@ -284,7 +303,7 @@ int ThreadPoolTask::getDisplayWidthFromLspci(const QString &info) { QString cmd = QString("lspci -v -s %1").arg(info); QString sInfo; - runCmd(cmd, sInfo); + runCmd(cmd, sInfo, kLspciTimeoutMs); QStringList lines = sInfo.split("\n"); foreach (const QString &line, lines) { if (!line.contains("Memory at")) { diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpooltask.h b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpooltask.h index bc37152ad..aa4ded8e7 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpooltask.h +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/threadpooltask.h @@ -33,18 +33,20 @@ class ThreadPoolTask : public QObject, public QRunnable private: /** * @brief runCmd : running a command - * @param cmd : the command - * @param info : command output + * @param cmd : 命令行(可带 "> 文件" 重定向) + * @param info : 命令输出 + * @param timeoutMs : 单条命令的等待上限;<=0 时沿用任务自己的 waitingTime */ - void runCmd(const QString &cmd, QString &info); + void runCmd(const QString &cmd, QString &info, int timeoutMs = -1); /** * @brief runAsteriskCmd * @param cmd * @param arg + * @param timeoutMs 单条命令的等待上限,<=0 时沿用任务自己的 waitingTime * @return info */ - QString runAsteriskCmd(const QString &cmd, const QString &arg); + QString runAsteriskCmd(const QString &cmd, const QString &arg, int timeoutMs = -1); /** * @brief runCmdToCache diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/mainjob.cpp b/deepin-devicemanager-server/deepin-deviceinfo/src/mainjob.cpp index 617c63d89..c0abb6b95 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/mainjob.cpp +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/mainjob.cpp @@ -16,10 +16,23 @@ #include #include +#include + using namespace DDLog; +// 一次全量刷新的最长等待时间(DBus 层面的"服务端忙"保底)。 +static constexpr int kFullRefreshTimeoutMs = 20000; + +// 启动/唤醒时同步"禁用/唤醒"策略所用的 hwinfo 等待上限。 +// 这段代码跑在主线程上(sqlCopytoKernel),一旦 hwinfo 卡住,整个进程的 +// D-Bus 派发都会停摆。实测约 400ms,这里给足余量。 +static constexpr int kPolicyHwinfoTimeoutMs = 15000; + static QMutex mainJobMutex; -static bool s_ServerIsUpdating = false; +static std::atomic s_ServerIsUpdating { false }; +// 供静态的 serverIsRunning() 查询"是否还有任务在写缓存", +// 让忙状态覆盖总超时之后仍在收尾的那段时间。 +static std::atomic s_pool { nullptr }; static bool s_ClientIsUpdating = false; MainJob::MainJob(const char *name, QObject *parent) @@ -28,6 +41,7 @@ MainJob::MainJob(const char *name, QObject *parent) , m_firstUpdate(true) { m_deviceInterface = new DeviceInterface(name, this); + s_pool = m_pool; // 守护进程启动的时候加载所有信息 updateAllDevice(); @@ -53,6 +67,16 @@ MainJob::MainJob(const char *name, QObject *parent) ); } +MainJob::~MainJob() +{ + s_pool = nullptr; + + if (mp_DetectThread) { + mp_DetectThread->setWorkingFlag(false); + mp_DetectThread->wait(2000); + } +} + void MainJob::sqlCopytoKernel() { ControlInterface::getInstance()->disableInDevice(); @@ -61,9 +85,18 @@ void MainJob::sqlCopytoKernel() QStringList options; options << "--netcard" << "--keyboard" << "--mouse" << "--usb"; process.start("hwinfo", options); - process.waitForFinished(-1); + if (!process.waitForFinished(kPolicyHwinfoTimeoutMs)) { + process.kill(); + process.waitForFinished(1000); + qCWarning(appLog) << "hwinfo timeout in sqlCopytoKernel, skip policy sync"; + return; + } QString info = process.readAllStandardOutput(); process.close(); + if (info.isEmpty()) { + qCWarning(appLog) << "hwinfo returned empty output in sqlCopytoKernel, skip policy sync"; + return; + } // init from sql db ControlInterface::getInstance()->disableOutDevice(info); ControlInterface::getInstance()->updateWakeup(info); @@ -90,7 +123,11 @@ void MainJob::slotWakeupHandle(bool isSleep) bool MainJob::serverIsRunning() { - return s_ServerIsUpdating; + if (s_ServerIsUpdating) + return true; + + ThreadPool *pool = s_pool.load(); + return pool != nullptr && pool->activeThreadCount() > 0; } bool MainJob::clientIsRunning() @@ -106,10 +143,7 @@ void MainJob::setWorkingFlag(bool flag) void MainJob::slotUsbChanged() { - // USB 热插拔走局部刷新,省掉与插拔无关的命令(lshw / upower / lscpu / - // lspci / lpstat / bluetoothctl / hwinfo --framebuffer)。 - // 客户端主动刷新与驱动操作完成走 slotRefreshRequest(),那里是全量刷新。 - executeClientInstruction("HOTPLUG"); + qCInfo(appLog) << "usb/bluetooth changed, cache refresh deferred to client request"; } void MainJob::slotRefreshRequest() @@ -127,11 +161,18 @@ void MainJob::slotDriverControl(bool success) void MainJob::updateAllDevice() { PERF_PRINT_BEGIN("POINT-01", "MainJob::updateAllDevice()"); + s_ServerIsUpdating = true; if (m_firstUpdate) m_pool->loadDeviceInfo(); else m_pool->updateDeviceInfo(); - m_pool->waitForDone(60000); + // 整个刷新(命令派发 + 全部任务结束)只在这里限时一次。 + if (!m_pool->waitForDone(kFullRefreshTimeoutMs)) { + qCWarning(appLog) << "device info refresh timed out after" + << kFullRefreshTimeoutMs << "ms, tasks still running:" + << m_pool->activeThreadCount(); + } + s_ServerIsUpdating = false; PERF_PRINT_END("POINT-01"); m_firstUpdate = false; } @@ -139,24 +180,12 @@ void MainJob::updateAllDevice() void MainJob::executeClientInstruction(const QString &instructions) { QMutexLocker locker(&mainJobMutex); - s_ServerIsUpdating = true; if (instructions.startsWith("DETECT")) { - // 原实现在这里用 thread()->msleep(1000) 硬睡主线程。DetectThread 已经 - // 轮询确认内核处理完插拔、MonitorUsb 也已等待 1s 去抖,这 1 秒纯属重复, - // 而且会阻塞 DeviceInterface 的 D-Bus 方法派发,直接去掉。 updateAllDevice(); - } else if (instructions.startsWith("HOTPLUG")) { - if (m_firstUpdate) { - updateAllDevice(); - } else { - // 只刷新与 USB 插拔相关的少量信息,避免全量命令占满 CPU - m_pool->updateHotplugInfo(); - } } else if (instructions.startsWith("START")) { if (m_firstUpdate) { updateAllDevice(); } } - s_ServerIsUpdating = false; } diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/mainjob.h b/deepin-devicemanager-server/deepin-deviceinfo/src/mainjob.h index f5d582e07..a60e9fb26 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/mainjob.h +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/mainjob.h @@ -16,6 +16,7 @@ class MainJob : public QObject public: explicit MainJob(const char *name, QObject *parent = nullptr); + ~MainJob() override; /** * @brief serverIsRunning @@ -37,8 +38,6 @@ class MainJob : public QObject private slots: /** * @brief slotUsbChanged usb 热插拔事件 - * - * 只刷新与插拔相关的信息,避免与插拔无关的命令占满 CPU。 */ void slotUsbChanged(); diff --git a/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp b/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp index 59ba79bcb..0840e272b 100644 --- a/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp +++ b/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -8,7 +8,8 @@ #include #include -#include +#include +#include #include using namespace DDLog; @@ -28,15 +29,20 @@ DBusInterface::DBusInterface() init(); } -bool DBusInterface::getInfo(const QString &key, QString &info) +bool DBusInterface::getInfo(const QString &key, QString &info, int timeoutMs) { - // 调用dbus接口获取设备信息 - QDBusReply reply = mp_Iface->call("getInfo", key); - if (reply.isValid()) { - info = reply.value(); + QDBusMessage msg = QDBusMessage::createMethodCall(SERVICE_NAME, DEVICE_SERVICE_PATH, + DEVICE_SERVICE_INTERFACE, "getInfo"); + msg << key; + + const QDBusMessage reply = QDBusConnection::systemBus().call( + msg, QDBus::Block, timeoutMs > 0 ? timeoutMs : -1); + if (reply.type() == QDBusMessage::ReplyMessage && !reply.arguments().isEmpty()) { + info = reply.arguments().first().toString(); return true; } else { - qCInfo(appLog) << "Error in getting info from getInfo ......................................."; + qCInfo(appLog) << "Error in getting info from getInfo ......................................." + << reply.errorName() << reply.errorMessage(); return false; } } diff --git a/deepin-devicemanager/src/GenerateDevice/DBusInterface.h b/deepin-devicemanager/src/GenerateDevice/DBusInterface.h index a154a3377..68b161e0e 100644 --- a/deepin-devicemanager/src/GenerateDevice/DBusInterface.h +++ b/deepin-devicemanager/src/GenerateDevice/DBusInterface.h @@ -1,5 +1,5 @@ // Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -38,9 +38,10 @@ class DBusInterface * @brief getInfo:获取信息 * @param key:命令关键字 * @param info:获取的设备信息 + * @param timeoutMs:D-Bus 同步调用超时(ms),<=0 表示使用 Qt 默认超时(25s) * @return 信息是否有效 */ - bool getInfo(const QString &key, QString &info); + bool getInfo(const QString &key, QString &info, int timeoutMs = -1); /** * @brief refreshInfo 用来通知后台刷新信息 diff --git a/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.cpp b/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.cpp index 3d812da9b..075a58261 100644 --- a/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.cpp +++ b/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.cpp @@ -7,25 +7,31 @@ #include "GenerateDevicePool.h" #include "DBusInterface.h" #include "DeviceManager.h" +#include "DDLog.h" #include #include #include +#include #include #include #include DWIDGET_USE_NAMESPACE -static bool firstLoadFlag = true; +using namespace DDLog; + +static constexpr int kServerIdlePollMs = 100; // 轮询间隔 +static constexpr int kMaxWaitServerIdleMs = 40000; // 整体等待上限,按真实耗时计算 +static constexpr int kServerStatusTimeoutMs = 30000; // 单次查询超时,需大于服务端刷新上限 +static constexpr int kPollStartGraceMs = 300; // 留给 refreshInfo 消息派发的时间 +static constexpr int kServerProbeRetryMs = 200; // 查询失败(服务未就绪)时的重试间隔 +static constexpr int kServerProbeRetryCount = 5; // 查询失败时的重试次数 LoadInfoThread::LoadInfoThread() : mp_ReadFilePool() , mp_GenerateDevicePool() - , m_Running(false) - , m_FinishedReadFilePool(false) - , m_Start(true) { connect(&mp_ReadFilePool, &GetInfoPool::finishedAll, this, &LoadInfoThread::slotFinishedReadFilePool); } @@ -47,69 +53,100 @@ LoadInfoThread::~LoadInfoThread() void LoadInfoThread::run() { - // 判断后台是否正处理update状态 - QString info; - DBusInterface::getInstance()->getInfo("is_server_running", info); - // 请求后台更新信息 m_Running = true; - if (!info.toInt()) { - m_Start = false; - mp_ReadFilePool.getAllInfo(); - mp_ReadFilePool.waitForDone(-1); - - bool readDataFlag = false; - int readNum = 0; - while (!readDataFlag) { - if (m_FinishedReadFilePool) { + + // 每次加载都先让服务端刷一遍缓存,再读。 + DBusInterface::getInstance()->refreshInfo(); + + // 服务端正在全量刷新时缓存可能只写了一半,先等它刷完再读。 + waitServerRefreshFinished(); + + mp_ReadFilePool.getAllInfo(); + mp_ReadFilePool.waitForDone(-1); + + bool readDataFlag = false; + int readNum = 0; + while (!readDataFlag) { + if (m_FinishedReadFilePool) { + mp_ReadFilePool.getAllInfo(); + mp_ReadFilePool.waitForDone(-1); + } + // 为了保证上面那个线程池完全结束 + long long begin = QDateTime::currentMSecsSinceEpoch(); + while (true) { + readDataFlag = !DeviceManager::instance()->cmdInfo("dmidecode4").isEmpty(); + if (readDataFlag && m_FinishedReadFilePool) + break; + long long end = QDateTime::currentMSecsSinceEpoch(); + if (end - begin > 4000) + break; + usleep(100); + } + if ((++readNum) > 3) { + if (m_FinishedReadFilePool && !readDataFlag) { mp_ReadFilePool.getAllInfo(); mp_ReadFilePool.waitForDone(-1); - } - // 为了保证上面那个线程池完全结束 - long long begin = QDateTime::currentMSecsSinceEpoch(); - while (true) { - readDataFlag = !DeviceManager::instance()->cmdInfo("dmidecode4").isEmpty(); - if (readDataFlag && m_FinishedReadFilePool) - break; - long long end = QDateTime::currentMSecsSinceEpoch(); - if (end - begin > 4000) - break; - usleep(100); - } - if ((++readNum) > 3) { - if (m_FinishedReadFilePool && !readDataFlag) { - mp_ReadFilePool.getAllInfo(); - mp_ReadFilePool.waitForDone(-1); - begin = QDateTime::currentMSecsSinceEpoch(); - while (true) { - if (m_FinishedReadFilePool) - break; - long long end = QDateTime::currentMSecsSinceEpoch(); - if (end - begin > 4000) - break; - usleep(100); - } + begin = QDateTime::currentMSecsSinceEpoch(); + while (true) { + if (m_FinishedReadFilePool) + break; + long long end = QDateTime::currentMSecsSinceEpoch(); + if (end - begin > 4000) + break; + usleep(100); } - break; } + break; } - - m_FinishedReadFilePool = false; - // generateDevice() 内部已等待所有设备生成任务完成,无需再次 waitForDone - mp_GenerateDevicePool.generateDevice(); } + m_FinishedReadFilePool = false; + // generateDevice() 内部已等待所有设备生成任务完成,无需再次 waitForDone + mp_GenerateDevicePool.generateDevice(); + emit finished("finish"); m_Running = false; } +void LoadInfoThread::waitServerRefreshFinished() +{ + // refreshInfo() 是异步调用,消息派发需要一点时间。不等这一会儿就去查, + // 第一轮很可能查到"空闲",结果又读到了旧缓存。 + msleep(kPollStartGraceMs); + + QElapsedTimer timer; + timer.start(); + + QString info; + int probeFailCount = 0; + while (timer.elapsed() < kMaxWaitServerIdleMs) { + info.clear(); + // 传入更长的超时:服务端刷新期间不处理 D-Bus 调用,查询会一直排队。 + // 但不能超过剩余预算,否则单次调用就能把总预算撑破(例如预算剩 1s + // 却发出一个 30s 的调用,实际要等 30s 才返回)。 + const int remainMs = kMaxWaitServerIdleMs - static_cast(timer.elapsed()); + const int timeoutMs = qMin(kServerStatusTimeoutMs, remainMs); + if (!DBusInterface::getInstance()->getInfo("is_server_running", info, timeoutMs)) { + // 服务尚未在总线上注册(如刚开机还没起来)时重试几次, + // 重试无果则当作服务不存在,继续读本地缓存。 + if (++probeFailCount > kServerProbeRetryCount) + return; + msleep(kServerProbeRetryMs); + continue; + } + probeFailCount = 0; + if (info.toInt() == 0) + return; + msleep(kServerIdlePollMs); + } + + qCWarning(appLog) << "wait server refresh finished timeout after" << timer.elapsed() + << "ms, load cache anyway"; +} + void LoadInfoThread::slotFinishedReadFilePool(const QString &) { m_FinishedReadFilePool = true; - // 首次加载刷新 - if (firstLoadFlag) { - firstLoadFlag = false; - emit finishedReadFilePool(); - } } void LoadInfoThread::setFramework(const QString &arch) diff --git a/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h b/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h index 440f285b0..2bd90fa76 100644 --- a/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h +++ b/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h @@ -1,5 +1,5 @@ // Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -8,6 +8,9 @@ #include #include + +#include + #include "GetInfoPool.h" #include "GenerateDevicePool.h" @@ -26,7 +29,6 @@ class LoadInfoThread : public QThread signals: void finished(const QString &message); - void finishedReadFilePool(); protected: void run() override; @@ -38,13 +40,17 @@ private slots: */ void slotFinishedReadFilePool(const QString &info); +private: + /** + * @brief waitServerRefreshFinished 等待服务端全量刷新结束 + */ + void waitServerRefreshFinished(); + private: GetInfoPool mp_ReadFilePool; GenerateDevicePool mp_GenerateDevicePool; - bool m_Running; // m_Running { false }; // m_FinishedReadFilePool { false }; // #include #include -#include #include DWIDGET_USE_NAMESPACE @@ -55,6 +54,7 @@ using namespace DDLog; static bool startScanningFlag = false; static int monitorNumber = 1; +static constexpr int kUPowerCmdTimeoutMs = 3000; static bool checkWaylandMode() { auto e = QProcessEnvironment::systemEnvironment(); @@ -80,10 +80,6 @@ MainWindow::MainWindow(QWidget *parent) // 初始化窗口相关的内容,比如界面布局,控件大小 initWindow(); - // 加载设备信息 - refreshDataBase(); - - // 关联信号槽 connect(mp_WorkingThread, &LoadInfoThread::finished, this, &MainWindow::slotLoadingFinish); connect(mp_DeviceWidget, &DeviceWidget::itemClicked, this, &MainWindow::slotListItemClicked); connect(mp_DeviceWidget, &DeviceWidget::refreshInfo, this, &MainWindow::slotRefreshInfo); @@ -119,22 +115,27 @@ MainWindow::MainWindow(QWidget *parent) mp_DriverScanWidget->refreshProgress(info, progress); }); connect(mp_DriverScanWidget, &DriverScanWidget::redetected, mp_DriverManager, &PageDriverManager::startScanning); + + // 加载设备信息。 + refreshDataBase(); + //get monitorNumber ThreadExecXrandr txgpu(true, !checkWaylandMode()); txgpu.start(); txgpu.wait(); monitorNumber = txgpu.getMonitorNumber(); - connect(mp_WorkingThread, &LoadInfoThread::finishedReadFilePool, this, [ = ]() { - refreshDataBaseLater(); - }); } -void MainWindow::refreshDataBaseLater() + +void MainWindow::refreshWithServerUpdate() { - DBusInterface::getInstance()->refreshInfo(); - QTimer::singleShot(2000, this, [ = ]() { //test the x86 the fast desktop PC need 2s - // 加载设备信息 - refreshDataBase(); - }); + // 加载进行中时直接忽略本次请求。 + if (!mp_WorkingThread || m_refreshing || mp_WorkingThread->isRunning()) { + qCDebug(appLog) << "refresh request ignored: load in progress"; + return; + } + + // 加载线程会在读缓存前发 refreshInfo() 并等刷新结束 + refreshDataBase(); } MainWindow::~MainWindow() @@ -164,13 +165,14 @@ MainWindow::~MainWindow() void MainWindow::refresh() { - //电池状态刷新 - refreshBatteryStatus(); - // 正在刷新,避免重复操作 if (m_refreshing || startScanningFlag || mp_DriverManager->isScanning() || mp_WorkingThread->isRunning()) return; + // 电池状态刷新放在防重入判断之后:本次刷新即将被忽略时,没必要再去 + // 访问 UPower(那是一串同步 D-Bus 调用,全跑在 GUI 线程上)。 + refreshBatteryStatus(); + if (mp_ButtonBox->checkedId() == 1) { startScanningFlag = true; } @@ -183,7 +185,8 @@ void MainWindow::refresh() mp_ButtonBox->buttonList().at(0)->click(); mp_DeviceWidget->clear(); - // 加载设备信息 + // 加载设备信息。用户主动刷新时缓存很可能已过期(期间插拔过设备), + // 加载线程会先请求服务端刷新、等它完成再读缓存。 refreshDataBase(); } @@ -197,7 +200,12 @@ void MainWindow::refreshBatteryStatus() QProcess process; QString command = "gdbus call --system --dest org.freedesktop.UPower --object-path /org/freedesktop/UPower --method org.freedesktop.UPower.EnumerateDevices"; process.start(command); - process.waitForFinished(); + if (!process.waitForFinished(kUPowerCmdTimeoutMs)) { + process.kill(); + process.waitForFinished(1000); + qWarning() << "gdbus EnumerateDevices timeout, skip battery refresh"; + return; + } QByteArray output = process.readAllStandardOutput(); QString outputStr = QString::fromLocal8Bit(output); @@ -449,14 +457,21 @@ void MainWindow::initWidgets() void MainWindow::refreshDataBase() { - if (mp_WorkingThread) { - /* 一定要与 restoreOverrideCursor 成对使用*/ - if(!m_statusCursorIsWait) { - DApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - m_statusCursorIsWait = true; - } - mp_WorkingThread->start(); + if (!mp_WorkingThread) + return; + + if (mp_WorkingThread->isRunning()) { + qCWarning(appLog) << "load thread still running, skip reload"; + return; + } + + /* 一定要与 restoreOverrideCursor 成对使用*/ + if(!m_statusCursorIsWait) { + DApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + m_statusCursorIsWait = true; } + + mp_WorkingThread->start(); } void MainWindow::slotSetPage(const QString &page) @@ -576,15 +591,11 @@ void MainWindow::slotListItemClicked(const QString &itemStr) txgpu.start(); txgpu.wait(); if(monitorNumber != txgpu.getMonitorNumber()) { - - QString info; - DBusInterface::getInstance()->getInfo("is_server_running", info); - //请求后台更新信息 - if (!info.toInt()) { - refreshDataBaseLater(); - } - qCDebug(appLog)<< "Monitor refreshInfo" << __LINE__ << QDateTime::currentDateTime().toString("hh:mm:ss") << info << monitorNumber; + qCDebug(appLog) << "Monitor refreshInfo" << __LINE__ + << QDateTime::currentDateTime().toString("hh:mm:ss") << monitorNumber; monitorNumber = txgpu.getMonitorNumber(); + + refreshWithServerUpdate(); } // 数据刷新时不处理界面刷新 @@ -603,8 +614,6 @@ void MainWindow::slotListItemClicked(const QString &itemStr) void MainWindow::slotRefreshInfo() { - refreshDataBaseLater(); - // 界面刷新 refresh(); } diff --git a/deepin-devicemanager/src/Page/MainWindow.h b/deepin-devicemanager/src/Page/MainWindow.h index 6a60c8fd7..531a5379d 100644 --- a/deepin-devicemanager/src/Page/MainWindow.h +++ b/deepin-devicemanager/src/Page/MainWindow.h @@ -1,5 +1,5 @@ // Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -122,13 +122,13 @@ class MainWindow : public DMainWindow void initWidgets(); /** - * @brief refreshDataBase:刷新设备信息 + * @brief refreshDataBase:重新加载设备信息 */ void refreshDataBase(); /** - * @brief refreshDataBaseLater:刷新设备信息 + * @brief refreshWithServerUpdate 让服务端全量刷新后重新加载设备信息(不重建界面) */ - void refreshDataBaseLater(); + void refreshWithServerUpdate(); private slots: /** * @brief slotSetPage