From de4cb5b34fb6a0411c17355fcce71abb9538f728 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 28 Aug 2024 11:55:01 +0200 Subject: [PATCH] [service] Submit state clear event outside of lock --- service/mgr/states.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/mgr/states.go b/service/mgr/states.go index c80d6771..f887a115 100644 --- a/service/mgr/states.go +++ b/service/mgr/states.go @@ -149,11 +149,11 @@ func (m *StateMgr) Remove(id string) { // Clear removes all states. func (m *StateMgr) Clear() { m.statesLock.Lock() - defer m.statesLock.Unlock() - m.states = nil + m.statesLock.Unlock() - m.statesEventMgr.Submit(m.export()) + // Submit event without lock, because callbacks might come back to change states. + defer m.statesEventMgr.Submit(m.Export()) } // Export returns the current states.