Add RW lock when iterating mQueue
This commit is contained in:
parent
503fec99a8
commit
e484d80314
@ -354,7 +354,8 @@ func cleanMQueue(mqueue map[string]*OpenLdapConnection, mqMtx *sync.Mutex, age t
|
|||||||
|
|
||||||
log.Printf("Start cleaning queue task: %d items in queue", len(mqueue))
|
log.Printf("Start cleaning queue task: %d items in queue", len(mqueue))
|
||||||
|
|
||||||
// Do we need read lock?
|
// We need lock here
|
||||||
|
mqMtx.Lock()
|
||||||
for uid, ldcon := range mqueue {
|
for uid, ldcon := range mqueue {
|
||||||
ok = false
|
ok = false
|
||||||
// Check if a close operation exist
|
// Check if a close operation exist
|
||||||
@ -366,11 +367,11 @@ func cleanMQueue(mqueue map[string]*OpenLdapConnection, mqMtx *sync.Mutex, age t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ok == true {
|
if ok == true {
|
||||||
mqMtx.Lock()
|
// We already in RW lock
|
||||||
delete(mqueue, uid)
|
delete(mqueue, uid)
|
||||||
mqMtx.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mqMtx.Unlock()
|
||||||
log.Printf("Finished cleaning queue task: %d items in queue", len(mqueue))
|
log.Printf("Finished cleaning queue task: %d items in queue", len(mqueue))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user