Repository navigation
Restart bt-agent when org.bluez loses its owner - #15097
omarchybot wants to merge 2 commits into
Conversation
An agent registration lives in the bluetoothd process that accepted it. When bluetoothd dies without a clean shutdown (a crash, a SIGKILL, a stop that times out) bt-agent stays alive and registered with nobody, so Restart=on-failure never fires and the replacement daemon has no agent to pair with. Watch org.bluez with gdbus monitor beside bt-agent and exit as soon as either the owner goes away or bt-agent exits, so systemd restarts it against the live daemon. bt-agent also does not exit on SIGTERM, so stopping the unit waited out the 90s stop timeout and ended failed. KillMode=mixed sends SIGTERM to the wrapper and SIGKILL to the rest once it has gone. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge; no new actionable defect was established. SummaryAdds a watcher that restarts
|
|
Verified at 629b95a on a worker built from the Omarchy ISO (BlueZ 5.87, bluez-tools 0.2.0, a virtual HCI controller via
Codex at medium effort reviewed it as a second opinion and found no defect in the change. It checked that the wrapper always exits 1 (owner loss, agent exit, monitor EOF), that a device name cannot match gdbus's whole owner-loss line, that systemd passes the quoting through intact, and that the default start limit is not exhausted by these restarts. It agreed with the two limits the description already states. Its independence is not guaranteed. The Labelled |
quattro removed tests that only read source text (#16334), and this branch's two systemd-test.sh checks grepped the unit for the exact ExecStart and KillMode lines it adds, so the conflict resolves to quattro's file and the branch now changes only the unit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This branch stopped merging into Re-verified at ae814b8 on a worker built from the Omarchy ISO (BlueZ 5.87, bluez-tools 0.2.0, a virtual HCI controller through
Codex at medium effort and muse-wonder (via pi, at high thinking) reviewed the merge as a second opinion. Both found the conflict resolution correct and the change proportionate. Neither found a defect in the change; their independence is not guaranteed. muse-wonder raised the case where Labelled |
An agent registration lives in the
bluetoothdprocess that accepted it. Whenbluetoothddies without a clean shutdown (a crash, a SIGKILL, a stop that runs into its timeout),bt-agentstays alive, still registered with a daemon that no longer exists.Restart=on-failurenever fires because nothing failed, systemd keeps reporting the agent as active, and the replacement daemon has no agent, so pairing a passkey device fails withNo agent available for request type 2.The unit now runs
gdbus monitor --system --dest org.bluezbesidebt-agentand exits 1 as soon as eitherorg.bluezloses its owner (matched on gdbus's wholeThe name org.bluez does not have an ownerline, so a device name cannot trigger it) orbt-agentexits. systemd then restarts it against the live daemon. This reacts to the ownership change rather than polling, and is the same supervision the reporter tested on their machine.bt-agentalso does not exit on SIGTERM, sosystemctl --user stop bt-agent.service, and with it every logout, waited out the 90-second stop timeout and left the unitfailed.KillMode=mixedsends SIGTERM to the wrapper and SIGKILL to the rest once it has gone;bluetoothddrops an agent along with its bus connection, so nothing is left registered.On a worker built from the Omarchy ISO (BlueZ 5.87, bluez-tools 0.2.0, a virtual HCI controller, the shipped user unit), with
quattroas it stands, SIGKILLingbluetoothdand starting it again leavesbt-agenton the same PID with no new registration. With this change it restarts once and re-registers within about two seconds. A cleansystemctl restart bluetooth.servicealready recovered before this change, becausebt-agentexits 1 when its daemon disconnects, and still does.Two limits are unchanged. If
bluetooth.serviceis not active when the restart comes two seconds later,ExecConditionskips the unit and nothing retries it. Stock takes the same path after every clean restart today; it is the race in #8962 and #13247 and is not addressed here. And the watcher subscribes at about the momentbt-agentregisters, so a daemon replaced within that window at unit start would go unnoticed.#13258, #13598, #13620 and #14795 edit this unit for other reasons and will conflict textually; #13258 also replaces
ExecStart.Fixes #11936