Commit 82f3d02e authored by Łukasz Magiera's avatar Łukasz Magiera

Fix lock usage in syncmount

parent 897edfb7
......@@ -35,14 +35,11 @@ func New(mounts []Mount) *Datastore {
type Datastore struct {
mounts []Mount
lk sync.Mutex
}
var _ ds.Datastore = (*Datastore)(nil)
func (d *Datastore) lookup(key ds.Key) (ds.Datastore, ds.Key, ds.Key) {
d.lk.Lock()
defer d.lk.Unlock()
for _, m := range d.mounts {
if m.Prefix.Equal(key) || m.Prefix.IsAncestorOf(key) {
s := strings.TrimPrefix(key.String(), m.Prefix.String())
......@@ -64,9 +61,6 @@ func (d *Datastore) lookup(key ds.Key) (ds.Datastore, ds.Key, ds.Key) {
// /ao/e/uh/ A /
// /aoe/ not matching
func (d *Datastore) lookupAll(key ds.Key) (dst []ds.Datastore, mountpoint, rest []ds.Key) {
d.lk.Lock()
defer d.lk.Unlock()
for _, m := range d.mounts {
p := m.Prefix.String()
if len(p) > 1 {
......@@ -257,6 +251,9 @@ func (mt *mountBatch) Delete(key ds.Key) error {
}
func (mt *mountBatch) Commit() error {
mt.lk.Lock()
defer mt.lk.Unlock()
for _, t := range mt.mounts {
err := t.Commit()
if err != nil {
......
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