Remove exclusiveAccess lock from database controller

This commit is contained in:
Patrick Pacher 2020-10-15 11:01:15 +02:00
parent 458d4e7f15
commit 7e4d441c2a
No known key found for this signature in database
GPG key ID: E8CD2DA160925A6D
4 changed files with 160 additions and 131 deletions

View file

@ -10,7 +10,6 @@ type Subscription struct {
q *query.Query
local bool
internal bool
canceled bool
Feed chan record.Record
}
@ -22,18 +21,13 @@ func (s *Subscription) Cancel() error {
return err
}
c.exclusiveAccess.Lock()
defer c.exclusiveAccess.Unlock()
if s.canceled {
return nil
}
s.canceled = true
close(s.Feed)
c.subscriptionLock.Lock()
defer c.subscriptionLock.Unlock()
for key, sub := range c.subscriptions {
if sub.q == s.q {
c.subscriptions = append(c.subscriptions[:key], c.subscriptions[key+1:]...)
close(s.Feed) // this close is guarded by the controllers subscriptionLock.
return nil
}
}