fix sync lock
This commit is contained in:
parent
0858dc865d
commit
875715803a
|
|
@ -57,7 +57,7 @@ type Config struct {
|
|||
type Poller struct {
|
||||
Plugins []string `json:"plugins" toml:"plugins" xml:"plugin" yaml:"plugins"`
|
||||
Debug bool `json:"debug" toml:"debug" xml:"debug,attr" yaml:"debug"`
|
||||
Quiet bool `json:"quiet,omitempty" toml:"quiet,omitempty" xml:"quiet,attr" yaml:"quiet"`
|
||||
Quiet bool `json:"quiet" toml:"quiet" xml:"quiet,attr" yaml:"quiet"`
|
||||
}
|
||||
|
||||
// LoadPlugins reads-in dynamic shared libraries.
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ func (u *UnifiPoller) Poller() Poller {
|
|||
// InitializeOutputs runs all the configured output plugins.
|
||||
// If none exist, or they all exit an error is returned.
|
||||
func (u *UnifiPoller) InitializeOutputs() error {
|
||||
outputSync.RLock()
|
||||
defer outputSync.RUnlock()
|
||||
|
||||
// Output plugin errors go into this channel.
|
||||
v := make(chan error)
|
||||
defer close(v)
|
||||
|
||||
var count int
|
||||
var count int // keep track of running output plugin count.
|
||||
|
||||
outputSync.RLock()
|
||||
|
||||
for _, o := range outputs {
|
||||
count++
|
||||
|
|
@ -68,10 +68,13 @@ func (u *UnifiPoller) InitializeOutputs() error {
|
|||
}(o)
|
||||
}
|
||||
|
||||
outputSync.RUnlock() // the loop below never exits, so cannot defer this.
|
||||
|
||||
if count < 1 {
|
||||
return errNoOutputPlugins
|
||||
}
|
||||
|
||||
// Wait for and return an error from any output plugin.
|
||||
for err := range v {
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Reference in New Issue