From e7a7b62392823d013052732eb9285b7dd28ff06e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=B6=8A?= <1939455790@qq.com> Date: Sun, 12 Jul 2026 23:15:44 +0000 Subject: [PATCH] fix(cli): wait out slow PackageManager1 activation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ll-cli probed org.deepin.linglong.PackageManager1 with a single Ping() that used the default 25s D-Bus timeout. The package manager daemon is D-Bus activated: before it can acquire its well-known bus name it has to be started by systemd and initialize the local ostree repository. On a cold start (and on slower systems/distros such as Ubuntu Kylin and Arch) this can exceed the single 25s window, so ll-cli surfaced a cryptic "org.freedesktop.DBus.Error.NoReply" and gave up immediately, which is what issue #1338 reports. Poll the peer instead: retry Ping() with a short per-call timeout up to a 90s overall deadline (matching systemd's default Type=dbus unit timeout), so a slow but successful activation is waited out rather than reported as a hard failure. When activation ultimately fails, point the user at the daemon service status and journal for actionable diagnostics. Closes #1338. Log: ll-cli now retries the PackageManager1 readiness check instead of failing on the first D-Bus timeout. Influence: only affects ll-cli's PackageManager1 activation path (waitForDBusPeerReady and the activation error message); no public API or behavior change for an already-running daemon. Signed-off-by: 王越 <1939455790@qq.com> --- libs/linglong/src/linglong/cli/cli.cpp | 34 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/libs/linglong/src/linglong/cli/cli.cpp b/libs/linglong/src/linglong/cli/cli.cpp index 5b791c436..b75db9cdc 100644 --- a/libs/linglong/src/linglong/cli/cli.cpp +++ b/libs/linglong/src/linglong/cli/cli.cpp @@ -127,14 +127,29 @@ Result waitForDBusPeerReady(const QString &service, { LINGLONG_TRACE("wait for dbus peer ready"); - auto peer = linglong::api::dbus::v1::DBusPeer(service, path, connection); - auto reply = peer.Ping(); - reply.waitForFinished(); - if (!reply.isValid()) { - return LINGLONG_ERR(reply.error().message().toStdString()); - } + using namespace std::chrono_literals; - return LINGLONG_OK; + constexpr auto perCallTimeout = 5s; + constexpr auto retryInterval = 1s; + constexpr auto totalDeadline = 90s; + + const auto startedAt = std::chrono::steady_clock::now(); + while (true) { + auto peer = linglong::api::dbus::v1::DBusPeer(service, path, connection); + peer.setTimeout(static_cast(std::chrono::milliseconds(perCallTimeout).count())); + + auto reply = peer.Ping(); + reply.waitForFinished(); + if (reply.isValid()) { + return LINGLONG_OK; + } + + if (std::chrono::steady_clock::now() - startedAt >= totalDeadline) { + return LINGLONG_ERR(reply.error().message().toStdString()); + } + + std::this_thread::sleep_for(retryInterval); + } } std::vector getAutoModuleList() noexcept @@ -967,7 +982,10 @@ Cli::initializeDBusPackageManager() "/org/deepin/linglong/PackageManager1", pkgManConn); if (!peerReady) { - return LINGLONG_ERR("Failed to activate org.deepin.linglong.PackageManager1", peerReady); + return LINGLONG_ERR("Failed to activate org.deepin.linglong.PackageManager1; check the " + "daemon with 'systemctl status org.deepin.linglong.PackageManager' and " + "'journalctl -u org.deepin.linglong.PackageManager -e'", + peerReady); } return std::make_unique("org.deepin.linglong.PackageManager1",