From a5892c71e0e94ed49ccb8bcd96339ae7055ca78c Mon Sep 17 00:00:00 2001 From: Nic Boet Date: Mon, 12 Oct 2026 16:18:48 -0500 Subject: [PATCH] fix: re-parse LinkedMonitors on a monitor reload Monitor::Reload() (the RELOAD action `zmu -m N -L` sends) re-reads the monitor row, which replaces linked_monitors_string, but the MonitorLinkExpression built from it is only rebuilt in connect(). The old links stayed in use until zmc reconnected: after changing LinkedMonitors from 3 to 4 and reloading, zmc kept scoring monitor 3 and ignored alarms on 4. Rebuild the expression in Reload(), under event_mutex, which Analyse() holds while it evaluates linked_monitors. fixes #5275 Co-Authored-By: Claude Opus 5.5 --- src/zm_monitor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 46417d870a..acf6d0979d 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2725,6 +2725,15 @@ void Monitor::Reload() { delete row; } // end if row + // Load() replaced linked_monitors_string, but the expression parsed from it + // is otherwise only rebuilt by connect(), so a changed LinkedMonitors did not + // apply until the next reconnect. Analyse() reads linked_monitors under + // event_mutex. + { + std::lock_guard lck(event_mutex); + ReloadLinkedMonitors(); + } + // Actions are otherwise only read during setup, so an action added or edited // in the web UI would not fire until the monitor's daemon was restarted. // Zones are already re-read by Load() above; actions have the same lifetime.