Use netsender.IsConfigured() rather than maintaining a global.

This commit is contained in:
Alan Noble 2018-05-07 09:26:22 +09:30
parent b2269ef8d8
commit de633f1061
1 changed files with 8 additions and 19 deletions

View File

@ -92,7 +92,6 @@ const (
// Globals
var (
configReceived bool = true
varSum int = 0
vars = make(map[string]string)
revidInst revid.Revid
@ -278,24 +277,14 @@ func netsenderInit() {
config.Logger = netsender.GetLogger()
netsender.Init(false)
netsender.ExternalReader = revidReportActions
//try get initial config
if err := netsender.GetConfig(); err != nil {
//default to a config?????
config.Logger.Log("Error", err.Error())
} else {
configReceived = true
}
}
//periodicNetsenderReport is called by the main function every monPeriod seconds. It makes sure a config has been recieved, and then
//reports back CPU stats and updates vars
func periodicNetsenderReport() {
if !configReceived {
if !netsender.IsConfigured() {
if err := netsender.GetConfig(); err != nil {
config.Logger.Log("Error", err.Error())
} else {
configReceived = true
}
}