1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Don't globally lock on driver initialization

This patch makes it such that plugin initialization is synchronized
based on the plugin name and not globally

Signed-off-by: Darren Shepherd <darren@rancher.com>
This commit is contained in:
Darren Shepherd 2015-08-18 22:04:22 -07:00
parent 3dc30d47e1
commit 164208fde5
2 changed files with 35 additions and 14 deletions

View file

@ -51,8 +51,8 @@ func Unregister(name string) bool {
// there is a VolumeDriver plugin available with the given name.
func Lookup(name string) (volume.Driver, error) {
drivers.Lock()
defer drivers.Unlock()
ext, ok := drivers.extensions[name]
drivers.Unlock()
if ok {
return ext, nil
}
@ -61,6 +61,12 @@ func Lookup(name string) (volume.Driver, error) {
return nil, fmt.Errorf("Error looking up volume plugin %s: %v", name, err)
}
drivers.Lock()
defer drivers.Unlock()
if ext, ok := drivers.extensions[name]; ok {
return ext, nil
}
d := NewVolumeDriver(name, pl.Client)
drivers.extensions[name] = d
return d, nil