From 94e3db7d8de23faed33cd1561169b02dd799a65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Thu, 16 May 2024 13:46:38 +0200 Subject: [PATCH] don't set connection loss if termination is in progress (test cases) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- monitor/mqtt_monitor.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/monitor/mqtt_monitor.go b/monitor/mqtt_monitor.go index 94c4b53..7d89c67 100644 --- a/monitor/mqtt_monitor.go +++ b/monitor/mqtt_monitor.go @@ -194,9 +194,11 @@ func (mms *MqttMonitor) MqttMsgHandler(_ mqtt.Client, msg mqtt.Message) { func (mms *MqttMonitor) onConnectionLost(_ mqtt.Client, err error) { log.Println("[app] [Monitor] Connection lost: " + err.Error()) // Handle connection loss here (e.g., reconnect attempts, logging) - mms.lostConnectionMutex.Lock() - mms.lostConnection = true - mms.lostConnectionMutex.Unlock() + if !mms.IsTerminated() { + mms.lostConnectionMutex.Lock() + mms.lostConnection = true + mms.lostConnectionMutex.Unlock() + } } func (mms *MqttMonitor) MonitorActiveParticipants() {