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