diff --git a/core/poller/config.go b/core/poller/config.go index f3a982f0..0b2f3002 100644 --- a/core/poller/config.go +++ b/core/poller/config.go @@ -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. diff --git a/core/poller/outputs.go b/core/poller/outputs.go index f0b5541e..80d8549b 100644 --- a/core/poller/outputs.go +++ b/core/poller/outputs.go @@ -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