diff --git a/pkg/minikube/registry/registry.go b/pkg/minikube/registry/registry.go index 9d83ce99248f..311094bde776 100644 --- a/pkg/minikube/registry/registry.go +++ b/pkg/minikube/registry/registry.go @@ -109,7 +109,7 @@ func (d DriverDef) String() string { type driverRegistry struct { drivers map[string]DriverDef - lock sync.Mutex + lock sync.RWMutex } func newRegistry() *driverRegistry { @@ -133,8 +133,8 @@ func (r *driverRegistry) Register(def DriverDef) error { // List returns a list of registered drivers func (r *driverRegistry) List() []DriverDef { - r.lock.Lock() - defer r.lock.Unlock() + r.lock.RLock() + defer r.lock.RUnlock() result := make([]DriverDef, 0, len(r.drivers)) @@ -147,7 +147,7 @@ func (r *driverRegistry) List() []DriverDef { // Driver returns a driver given a name func (r *driverRegistry) Driver(name string) DriverDef { - r.lock.Lock() - defer r.lock.Unlock() + r.lock.RLock() + defer r.lock.RUnlock() return r.drivers[name] } diff --git a/third_party/go9p/srv_file.go b/third_party/go9p/srv_file.go index 05c7fa93183b..9f34525a6725 100644 --- a/third_party/go9p/srv_file.go +++ b/third_party/go9p/srv_file.go @@ -81,7 +81,7 @@ const ( // The srvFile type represents a file (or directory) served by the file server. type srvFile struct { - sync.Mutex + sync.RWMutex Dir flags FFlags @@ -239,13 +239,13 @@ func (f *srvFile) Rename(name string) error { func (p *srvFile) Find(name string) *srvFile { var f *srvFile - p.Lock() + p.RLock() for f = p.cfirst; f != nil; f = f.next { if name == f.Name { break } } - p.Unlock() + p.RUnlock() return f } @@ -496,13 +496,13 @@ func (*Fsrv) Clunk(req *SrvReq) { func (*Fsrv) Remove(req *SrvReq) { fid := req.Fid.Aux.(*FFid) f := fid.F - f.Lock() + f.RLock() if f.cfirst != nil { - f.Unlock() + f.RUnlock() req.RespondError(Enotempty) return } - f.Unlock() + f.RUnlock() if rop, ok := (f.ops).(FRemoveOp); ok { err := rop.Remove(fid)