From c3d2043caf5c0edd94af5aa23e218904f8a6d36f Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Sat, 22 Jun 2019 18:58:12 +0100 Subject: [PATCH] Reverts c0a628d65b024d1c1a95f9e6a0419d356da1e973 Fixes #540 --- registry/gossip/util.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/registry/gossip/util.go b/registry/gossip/util.go index 75fb2dbf..0fa8116d 100644 --- a/registry/gossip/util.go +++ b/registry/gossip/util.go @@ -115,20 +115,27 @@ func delNodes(old, del []*registry.Node) []*registry.Node { func delServices(old, del []*registry.Service) []*registry.Service { var services []*registry.Service + for _, o := range old { + srv := new(registry.Service) + *srv = *o + var rem bool + for _, s := range del { - if o.Version == s.Version { - s.Nodes = delNodes(s.Nodes, o.Nodes) - if len(s.Nodes) == 0 { + if srv.Version == s.Version { + srv.Nodes = delNodes(srv.Nodes, s.Nodes) + + if len(srv.Nodes) == 0 { rem = true - break } } } + if !rem { - services = append(services, o) + services = append(services, srv) } } + return services }