From 1d1c8f99c562fb9a959a0127e094556e5d98db54 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 9 Dec 2015 15:44:59 +0200 Subject: [PATCH] made some methods private and extra locking --- scheduler/scheduler.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index 7a891def1..bbbd34a71 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -105,25 +105,27 @@ func (s *Scheduler) Reload(protect bool) { case <-s.loopChecker: t.Stop() // cancel reload case <-t.C: - s.LoadActionPlans() - s.Restart() + s.loadActionPlans() + s.restart() t.Stop() s.waitingReload = false } }() } else { - s.LoadActionPlans() - s.Restart() + s.loadActionPlans() + s.restart() } } -func (s *Scheduler) LoadActionPlans() { +func (s *Scheduler) loadActionPlans() { actionPlans, err := s.storage.GetAllActionPlans() if err != nil && err != utils.ErrNotFound { utils.Logger.Warning(fmt.Sprintf(" Cannot get action plans: %v", err)) } utils.Logger.Info(fmt.Sprintf(" processing %d action plans", len(actionPlans))) // recreate the queue + s.Lock() + defer s.Unlock() s.queue = engine.ActionPlanPriotityList{} for key, aps := range actionPlans { toBeSaved := false @@ -167,7 +169,7 @@ func (s *Scheduler) LoadActionPlans() { utils.Logger.Info(fmt.Sprintf(" queued %d action plans", len(s.queue))) } -func (s *Scheduler) Restart() { +func (s *Scheduler) restart() { if s.schedulerStarted { s.restartLoop <- true }