mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Updated guardian
This commit is contained in:
committed by
Dan Christian Bogos
parent
7c8103de3c
commit
36aab43e90
@@ -56,17 +56,11 @@ func (gl *GuardianLocker) lockItem(itmID string) {
|
||||
gl.lkMux.Lock()
|
||||
itmLock, exists := gl.locks[itmID]
|
||||
if !exists {
|
||||
itmLock = &itemLock{lk: make(chan struct{}, 1)}
|
||||
gl.locks[itmID] = itmLock
|
||||
itmLock.lk <- struct{}{}
|
||||
}
|
||||
itmLock.cnt++
|
||||
select {
|
||||
case <-itmLock.lk:
|
||||
gl.locks[itmID] = &itemLock{lk: make(chan struct{}, 1), cnt: 1}
|
||||
gl.lkMux.Unlock()
|
||||
return
|
||||
default: // move further so we can unlock
|
||||
}
|
||||
itmLock.cnt++
|
||||
gl.lkMux.Unlock()
|
||||
<-itmLock.lk
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user