Commit 0f07328c authored by Jeromy's avatar Jeromy

fix locking in syncbatch

parent 19e39c85
......@@ -92,24 +92,24 @@ func (d *MutexDatastore) Close() error {
}
type syncBatch struct {
lk sync.Mutex
batch ds.Batch
mds *MutexDatastore
}
func (b *syncBatch) Put(key ds.Key, val interface{}) error {
b.lk.Lock()
defer b.lk.Unlock()
b.mds.Lock()
defer b.mds.Unlock()
return b.batch.Put(key, val)
}
func (b *syncBatch) Delete(key ds.Key) error {
b.lk.Lock()
defer b.lk.Unlock()
b.mds.Lock()
defer b.mds.Unlock()
return b.batch.Delete(key)
}
func (b *syncBatch) Commit() error {
b.lk.Lock()
defer b.lk.Unlock()
b.mds.Lock()
defer b.mds.Unlock()
return b.batch.Commit()
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment