2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-02 11:46:36 +00:00

fuse: Use Mutex instead of RWMutex

This commit is contained in:
Alexander Neumann 2017-06-17 23:00:38 +02:00
parent 0d3674245b
commit 47282abfa4

View File

@ -68,7 +68,7 @@ type SnapshotsDir struct {
blobsize *BlobSizeCache blobsize *BlobSizeCache
// knownSnapshots maps snapshot timestamp to the snapshot // knownSnapshots maps snapshot timestamp to the snapshot
sync.RWMutex sync.Mutex
knownSnapshots map[string]SnapshotWithId knownSnapshots map[string]SnapshotWithId
processed restic.IDSet processed restic.IDSet
} }
@ -141,9 +141,9 @@ func (sn *SnapshotsDir) updateCache(ctx context.Context) error {
} }
func (sn *SnapshotsDir) get(name string) (snapshot SnapshotWithId, ok bool) { func (sn *SnapshotsDir) get(name string) (snapshot SnapshotWithId, ok bool) {
sn.RLock() sn.Lock()
snapshot, ok = sn.knownSnapshots[name] snapshot, ok = sn.knownSnapshots[name]
sn.RUnlock() sn.Unlock()
debug.Log("get(%s) -> %v %v", name, snapshot, ok) debug.Log("get(%s) -> %v %v", name, snapshot, ok)
return snapshot, ok return snapshot, ok
} }
@ -155,8 +155,8 @@ func (sn *SnapshotsDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
return nil, err return nil, err
} }
sn.RLock() sn.Lock()
defer sn.RUnlock() defer sn.Unlock()
ret := make([]fuse.Dirent, 0) ret := make([]fuse.Dirent, 0)
for timestamp, snapshot := range sn.knownSnapshots { for timestamp, snapshot := range sn.knownSnapshots {