Skip to content

Commit

Permalink
[service] Submit state clear event outside of lock
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Aug 28, 2024
1 parent c6ddaf8 commit de4cb5b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions service/mgr/states.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit de4cb5b

Please sign in to comment.