From cae087af733032749bd88bd5711ce61258895d81 Mon Sep 17 00:00:00 2001 From: roos Date: Thu, 26 Sep 2019 16:04:21 +0200 Subject: [PATCH] discovery: Call correct callback when cleaning dynamic --- go/lib/infra/modules/itopo/cleaner.go | 5 ++++- go/lib/infra/modules/itopo/itopo.go | 10 +++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/go/lib/infra/modules/itopo/cleaner.go b/go/lib/infra/modules/itopo/cleaner.go index 44fb99fe14..a9fcb20159 100644 --- a/go/lib/infra/modules/itopo/cleaner.go +++ b/go/lib/infra/modules/itopo/cleaner.go @@ -18,6 +18,7 @@ import ( "context" "time" + "github.com/scionproto/scion/go/lib/infra/modules/itopo/internal/metrics" "github.com/scionproto/scion/go/lib/log" "github.com/scionproto/scion/go/lib/periodic" ) @@ -44,6 +45,8 @@ func (c cleaner) Run(ctx context.Context) { log.FromCtx(ctx).Info("[itopo.cleaner] Dropping expired dynamic topology", "ts", st.topo.dynamic.Timestamp, "ttl", st.topo.dynamic.TTL, "expired", st.topo.dynamic.Expiry()) - st.dropDynamic() + st.topo.dynamic = nil + call(st.clbks.CleanDynamic) + metrics.Current.Active().Set(0) } } diff --git a/go/lib/infra/modules/itopo/itopo.go b/go/lib/infra/modules/itopo/itopo.go index fb0bf7752d..9cd3ee9c73 100644 --- a/go/lib/infra/modules/itopo/itopo.go +++ b/go/lib/infra/modules/itopo/itopo.go @@ -246,12 +246,6 @@ func (s *state) updateDynamic(dynamic *topology.Topo) { metrics.Current.Expiry(cl).Set(metrics.Expiry(dynamic.Expiry())) } -func (s *state) dropDynamic() { - s.topo.dynamic = nil - call(s.clbks.DropDynamic) - metrics.Current.Active().Set(0) -} - func (s *state) beginSetDynamic(dynamic *topology.Topo) (Transaction, error) { s.Lock() defer s.Unlock() @@ -329,7 +323,9 @@ func (s *state) beginSetStatic(static *topology.Topo, allowed bool) (Transaction func (s *state) updateStatic(static *topology.Topo) { // Drop dynamic topology if necessary. if s.validator.MustDropDynamic(static, s.topo.static) && s.topo.dynamic != nil { - s.dropDynamic() + s.topo.dynamic = nil + call(s.clbks.DropDynamic) + metrics.Current.Active().Set(0) } s.topo.static = static call(s.clbks.UpdateStatic)