Fix locking in PutMany implementations

This commit is contained in:
Daniel 2020-10-12 13:54:27 +02:00
parent e5a72ffa37
commit 6a58ce5a7a
2 changed files with 27 additions and 22 deletions

View file

@ -66,7 +66,7 @@ func (hm *HashMap) PutMany(shadowDelete bool) (chan<- record.Record, <-chan erro
// start handler
go func() {
for r := range batch {
hm.putOrDelete(shadowDelete, r)
hm.batchPutOrDelete(shadowDelete, r)
}
errs <- nil
}()
@ -74,7 +74,10 @@ func (hm *HashMap) PutMany(shadowDelete bool) (chan<- record.Record, <-chan erro
return batch, errs
}
func (hm *HashMap) putOrDelete(shadowDelete bool, r record.Record) {
func (hm *HashMap) batchPutOrDelete(shadowDelete bool, r record.Record) {
r.Lock()
defer r.Unlock()
hm.dbLock.Lock()
defer hm.dbLock.Unlock()