mirror of
https://github.com/safing/portbase
synced 2026-05-04 22:52:05 +00:00
Remove exclusiveAccess lock from database controller
This commit is contained in:
parent
458d4e7f15
commit
7e4d441c2a
4 changed files with 160 additions and 131 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue