Account for racecondition in deleting/closing update channel

This commit tries to address the possible raceondition  that can happen
if a client closes its connection after we have fetched it from the
syncmap before sending the message.

To try to avoid introducing new dead lock conditions, all messages sent
to updateChannel has been moved into a function, which handles the
locking (instead of calling it all over the place)

The same lock is used around the delete/close function.
This commit is contained in:
Kristoffer Dalby
2021-08-20 16:52:34 +01:00
parent 1f422af1c8
commit 88d7ac04bf
3 changed files with 46 additions and 28 deletions

3
app.go
View File

@@ -58,7 +58,8 @@ type Headscale struct {
aclPolicy *ACLPolicy
aclRules *[]tailcfg.FilterRule
clientsUpdateChannels sync.Map
clientsUpdateChannels sync.Map
clientsUpdateChannelMutex sync.Mutex
lastStateChange sync.Map
}