Fixes plugin file descriptor leak on plugin discovery
Signed-off-by: Clinton Kitson <clintonskitson@gmail.com>
This commit is contained in:
parent
c8da8b3693
commit
f08caca8a0
1 changed files with 14 additions and 4 deletions
|
@ -199,17 +199,27 @@ func GetAll(imp string) ([]*Plugin, error) {
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
chPl := make(chan plLoad, len(pluginNames))
|
chPl := make(chan *plLoad, len(pluginNames))
|
||||||
|
var wg sync.WaitGroup
|
||||||
for _, name := range pluginNames {
|
for _, name := range pluginNames {
|
||||||
|
if pl, ok := storage.plugins[name]; ok {
|
||||||
|
chPl <- &plLoad{pl, nil}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
go func(name string) {
|
go func(name string) {
|
||||||
|
defer wg.Done()
|
||||||
pl, err := loadWithRetry(name, false)
|
pl, err := loadWithRetry(name, false)
|
||||||
chPl <- plLoad{pl, err}
|
chPl <- &plLoad{pl, err}
|
||||||
}(name)
|
}(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
close(chPl)
|
||||||
|
|
||||||
var out []*Plugin
|
var out []*Plugin
|
||||||
for i := 0; i < len(pluginNames); i++ {
|
for pl := range chPl {
|
||||||
pl := <-chPl
|
|
||||||
if pl.err != nil {
|
if pl.err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue