From 25796ef802dbdefcf251c926740674a5a0683d6c Mon Sep 17 00:00:00 2001 From: Vitaly Grinberg Date: Mon, 22 Jun 2026 20:32:10 +0300 Subject: [PATCH] Fix chronyd NTP failover MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit stop/start chronyd process instead of chronyc offline/online The chronyc offline command was unreliable — chronyd could re-acquire NTP sources despite being told to go offline, causing clock frequency interference with phc2sys (clockcheck events). Replace with process stop/start, using the same pattern as phc2sys. The disable path uses `go p.cmdStop()` (non-blocking) to avoid a deadlock: cmdStop blocks on exitCh, but the ntpfailover FSM callback runs inside the process scanner goroutine which must finish before cmdRun can send to exitCh. Co-authored-by: Cursor --- pkg/daemon/daemon.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 8b4a83e55..7b858f17f 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -1262,11 +1262,14 @@ func (p *ptpProcess) cmdSetEnabled(enabled bool) { switch p.name { case "chronyd": if enabled { - _, _ = exec.Command("chronyc", "-h", ChronydSocketPath, "online").Output() - processStatus(p.c, p.name, p.messageTag, PtpProcessUp) + if p.Stopped() && p.cmd != nil { + cmd := p.cmd + newCmd := exec.Command(cmd.Args[0], cmd.Args[1:]...) + p.cmd = newCmd + go p.cmdRun(p.dn.stdoutToSocket, &(p.dn.pluginManager)) + } } else { - _, _ = exec.Command("chronyc", "-h", ChronydSocketPath, "offline").Output() - processStatus(p.c, p.name, p.messageTag, PtpProcessDown) + go p.cmdStop() } case "phc2sys": if enabled {