mirror of
https://github.com/safing/portbase
synced 2025-09-09 13:55:47 +00:00
Fix race condition in database package. Simplify db locking
This commit is contained in:
parent
93a0b27ea2
commit
50a10485e1
3 changed files with 34 additions and 46 deletions
|
@ -35,10 +35,8 @@ func RegisterHook(q *query.Query, hook Hook) (*RegisteredHook, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
c.readLock.Lock()
|
||||
defer c.readLock.Unlock()
|
||||
c.writeLock.Lock()
|
||||
defer c.writeLock.Unlock()
|
||||
c.exclusiveAccess.Lock()
|
||||
defer c.exclusiveAccess.Unlock()
|
||||
|
||||
rh := &RegisteredHook{
|
||||
q: q,
|
||||
|
@ -55,10 +53,8 @@ func (h *RegisteredHook) Cancel() error {
|
|||
return err
|
||||
}
|
||||
|
||||
c.readLock.Lock()
|
||||
defer c.readLock.Unlock()
|
||||
c.writeLock.Lock()
|
||||
defer c.writeLock.Unlock()
|
||||
c.exclusiveAccess.Lock()
|
||||
defer c.exclusiveAccess.Unlock()
|
||||
|
||||
for key, hook := range c.hooks {
|
||||
if hook.q == h.q {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue