12308: Use RWMutex for filehandle map.
authorTom Clegg <tom@tomclegg.ca>
Wed, 12 Feb 2020 16:39:18 +0000 (11:39 -0500)
committerTom Clegg <tom@tomclegg.ca>
Wed, 12 Feb 2020 16:39:18 +0000 (11:39 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/mount/fs.go

index 774948f574607b04f8548837720e6ba5c06c7c2f..c18c83d86bd88da246c46ec5ed28f363dd29c18c 100644 (file)
@@ -36,7 +36,7 @@ type keepFS struct {
        root   arvados.CustomFileSystem
        open   map[uint64]*sharedFile
        lastFH uint64
-       sync.Mutex
+       sync.RWMutex
 
        // If non-nil, this channel will be closed by Init() to notify
        // other goroutines that the mount is ready.
@@ -62,8 +62,8 @@ func (fs *keepFS) newFH(f arvados.File) uint64 {
 }
 
 func (fs *keepFS) lookupFH(fh uint64) *sharedFile {
-       fs.Lock()
-       defer fs.Unlock()
+       fs.RLock()
+       defer fs.RUnlock()
        return fs.open[fh]
 }