From c0551cffebdf0accc71a4f0b0bf56c374176328c Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Thu, 10 Mar 2016 20:57:35 -0800 Subject: table: remove empty destinations after withdraw Signed-off-by: FUJITA Tomonori --- table/table_manager.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'table') diff --git a/table/table_manager.go b/table/table_manager.go index 8eeff459..a40e1221 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -221,17 +221,28 @@ func (manager *TableManager) calculate(ids []string, destinations []*Destination withdrawn := make([]*Path, 0, len(destinations)) best := make(map[string][]*Path, len(ids)) - for _, destination := range destinations { + emptyDsts := make([]*Destination, 0, len(destinations)) + + for _, dst := range destinations { log.WithFields(log.Fields{ "Topic": "table", - "Key": destination.GetNlri().String(), + "Key": dst.GetNlri().String(), }).Debug("Processing destination") - paths, n, w := destination.Calculate(ids) + paths, n, w := dst.Calculate(ids) for id, path := range paths { best[id] = append(best[id], path) } newly = append(newly, n...) withdrawn = append(withdrawn, w...) + + if len(dst.knownPathList) == 0 { + emptyDsts = append(emptyDsts, dst) + } + } + + for _, dst := range emptyDsts { + t := manager.Tables[dst.Family()] + t.deleteDest(dst) } return best, newly, withdrawn } -- cgit v1.2.3